PowerTools SPREAD for Windows Forms 8.0J
GetPreferredWidth メソッド


指定した列内のテキストをすべて表示するのに最低限必要な幅を取得します。
構文
'Declaration
 
Public Function GetPreferredWidth() As Single
'使用法
 
Dim instance As Column
Dim value As Single
 
value = instance.GetPreferredWidth()
public float GetPreferredWidth()

戻り値の型

幅(ピクセル単位)を表す単精度浮動小数点数
解説

テキスト型セルまたはテキストを含むヘッダセルの場合は、テキスト型セルまたはヘッダセルのWordWrapプロパティをFalseに設定して、ワードラップを必ず無効にしてください。

このメソッドまたはSheetView.GetPreferredColumnWidthメソッドを使用することで、列の幅をセルのデータに基づいて設定できます。詳細については、「データに合わせたサイズ」を参照してください。

次のサンプルコードは、最初のセルのテキストに基づいて列の幅を決定します。
FarPoint.Win.Spread.Column col;
float size;
col = fpSpread1.ActiveSheet.Columns[0];
fpSpread1.ActiveSheet.Cells[0, 0].Text = "This text will be used to determine the width of the column";
size = col.GetPreferredWidth();
col.Width = size;
Dim col As FarPoint.Win.Spread.Column
Dim size As Single
col = FpSpread1.ActiveSheet.Columns(0)
FpSpread1.ActiveSheet.Cells(0, 0).Text = "This text will be used to determine the width of the column"
size = col.GetPreferredWidth()
col.Width = size
参照

Column クラス
Column メンバ
GetPreferredColumnWidth メソッド

開発者ガイド

データに合わせたサイズ

 

 


© 2004-2015, GrapeCity inc. All rights reserved.