SPREAD for ASP.NET 8.0J サンプルコード集
編集時の書式を設定する

セル型のEditModeプロパティに書式を設定します。EditModeプロパティに設定した書式は、セルの編集開始および終了時に適用されます。EditModeプロパティは通貨型、日付型、倍精度型、整数型で使用できます。

実行例:

セルにデータを入力しています。

[Enter]キーで編集終了した後:

3桁区切りの書式が適用されます。

//数値書式を3桁区切りに設定します
System.Globalization.NumberFormatInfo ninfo = (System.Globalization.NumberFormatInfo)System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone();
ninfo.NumberGroupSizes = new int[] { 3 };

//整数型セル型を作成します
IntegerCellType intCell = new IntegerCellType();
//表示時の書式を設定します     
intCell.NumberFormat = ninfo;  
//編集開始/終了時の書式を設定します     
intCell.EditMode.NumberFormat = ninfo;
FpSpread1.Cells[0, 1].CellType = intCell;
'数値書式を3桁区切りに設定します
Dim ninfo As System.Globalization.NumberFormatInfo = DirectCast(System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.Clone(), System.Globalization.NumberFormatInfo)
ninfo.NumberGroupSizes = New Integer() {3}

'整数型セル型を作成します
Dim intCell As New IntegerCellType()
'表示時の書式を設定します     
intCell.NumberFormat = ninfo
'編集開始/終了時の書式を設定します     
intCell.EditMode.NumberFormat = ninfo
FpSpread1.Cells(0, 1).CellType = intCell

 

 


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