GrapeCity SPREAD for Windows Forms 11.0J
GetPreferredColumnWidth(Int32,PreferredSizeColumnOptions) メソッド


列インデックス
最適な幅を取得するときのオプション
このシートの指定した列にある最も幅の広いセル(テキスト内容に基づく)の幅を取得します。
構文
'Declaration
 
Public Overloads Function GetPreferredColumnWidth( _
   ByVal column As Integer, _
   ByVal flags As PreferredSizeColumnOptions _
) As Single
'使用法
 
Dim instance As SheetView
Dim column As Integer
Dim flags As PreferredSizeColumnOptions
Dim value As Single
 
value = instance.GetPreferredColumnWidth(column, flags)
public float GetPreferredColumnWidth( 
   int column,
   PreferredSizeColumnOptions flags
)

パラメータ

column
列インデックス
flags
最適な幅を取得するときのオプション
解説
セルの複合スタイルのレンダラーがIWordWrapSupportインタフェースを実装していて、そのWordWrapプロパティがTrueを返す場合、セルの内容は複数行に折り返されます。
次のサンプルコードは、GetPreferredColumnWidthメソッドを使用します。
fpSpread1.ActiveSheet.ColumnHeader.Cells[0,2].Text = "Column Header Text";
fpSpread1.ActiveSheet.Cells[1, 1].Text = "Text in cell (1, 1)";
FarPoint.Win.Spread.CellType.TextCellType textcell = new FarPoint.Win.Spread.CellType.TextCellType();
textcell.WordWrap = true;
fpSpread1.ActiveSheet.Cells[2, 2].CellType = textcell;
fpSpread1.ActiveSheet.Cells[2, 2].Text = "Spread Windows Forms and the Funnel Chart";
fpSpread1.AutoFitColumnOptions = FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeHeaders | FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeSpans;
fpSpread1.AutoFitRowOptions = FarPoint.Win.Spread.PreferredSizeRowOptions.ExcludeHeaders;

private void button1_Click(object sender, EventArgs e)
        {
float size;
size = fpSpread1.ActiveSheet.GetPreferredColumnWidth(2, FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeHeaders | FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeSpans);
textBox1.Text = size.ToString();
        }
FpSpread1.ActiveSheet.ColumnHeader.Cells(0, 2).Text = "Column Header Text"
FpSpread1.ActiveSheet.Cells(1, 1).Text = "Text in cell (1, 1)"
Dim textcell As New FarPoint.Win.Spread.CellType.TextCellType()
textcell.WordWrap = True
FpSpread1.ActiveSheet.Cells(2, 2).CellType = textcell
FpSpread1.ActiveSheet.Cells(2, 2).Text = "Spread Windows Forms and the Funnel Chart"
FpSpread1.AutoFitColumnOptions = FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeHeaders Or FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeSpans
FpSpread1.AutoFitRowOptions = FarPoint.Win.Spread.PreferredSizeRowOptions.ExcludeHeaders

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim size As Integer
size = FpSpread1.ActiveSheet.GetPreferredColumnWidth(2, FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeHeaders Or FarPoint.Win.Spread.PreferredSizeColumnOptions.ExcludeSpans)
TextBox1.Text = size
End Sub
参照

SheetView クラス
SheetView メンバ
オーバーロード一覧

 

 


© 2004-2018, GrapeCity Inc. All rights reserved.