作成日: 2017/03/29 最終更新日: 2017/03/29
文書種別
使用方法
詳細
セル型のEditModeプロパティにてセルの編集を開始した際に適用される書式を設定することができます。EditModeプロパティを使用することで、書式がセルの編集開始/終了時に自動的に適用されます。通貨型、日付時刻型、倍精度型、整数型セルでEditModeプロパティが用意されています。
以下のサンプルコードでは、表示時は3桁のカンマ区切り書式、編集時は桁区切りなしの書式を設定しています。
(1)A1セルをダブルクリックして編集を開始すると、桁区切り記号なしの値(例:1000)になります。
(2)[Enter]キーを押下して編集を終了すると3桁区切りの値(例:1,000)になります。
◎サンプルコード(VB)
◎サンプルコード(C#)
以下のサンプルコードでは、表示時は3桁のカンマ区切り書式、編集時は桁区切りなしの書式を設定しています。
(1)A1セルをダブルクリックして編集を開始すると、桁区切り記号なしの値(例:1000)になります。
(2)[Enter]キーを押下して編集を終了すると3桁区切りの値(例:1,000)になります。
◎サンプルコード(VB)
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If IsPostBack Then
Return
End If
' 整数型セルの設定
Dim ic As New FarPoint.Web.Spread.IntegerCellType
' 表示時の書式設定
Dim ninfo1 As Globalization.NumberFormatInfo = CType(Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone(), Globalization.NumberFormatInfo)
ninfo1.NumberGroupSizes = New Int32() {3} '整数部は3桁区切り
ic.NumberFormat = ninfo1
' 編集時の書式設定
Dim ninfo2 As Globalization.NumberFormatInfo = CType(Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone(), Globalization.NumberFormatInfo)
ninfo2.NumberGroupSizes = New Int32() {0} '桁区切りなし
ic.EditMode.NumberFormat = ninfo2
'セル型を1列目に設定
FpSpread1.ActiveSheetView.Columns(0).CellType = ic
FpSpread1.ActiveSheetView.Cells(0, 0).Value = 1000
End Sub
If IsPostBack Then
Return
End If
' 整数型セルの設定
Dim ic As New FarPoint.Web.Spread.IntegerCellType
' 表示時の書式設定
Dim ninfo1 As Globalization.NumberFormatInfo = CType(Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone(), Globalization.NumberFormatInfo)
ninfo1.NumberGroupSizes = New Int32() {3} '整数部は3桁区切り
ic.NumberFormat = ninfo1
' 編集時の書式設定
Dim ninfo2 As Globalization.NumberFormatInfo = CType(Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone(), Globalization.NumberFormatInfo)
ninfo2.NumberGroupSizes = New Int32() {0} '桁区切りなし
ic.EditMode.NumberFormat = ninfo2
'セル型を1列目に設定
FpSpread1.ActiveSheetView.Columns(0).CellType = ic
FpSpread1.ActiveSheetView.Cells(0, 0).Value = 1000
End Sub
◎サンプルコード(C#)
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
return;
}
// 整数型セルの設定
FarPoint.Web.Spread.IntegerCellType ic = new FarPoint.Web.Spread.IntegerCellType();
// 表示時の書式設定
System.Globalization.NumberFormatInfo ninfo1 = (System.Globalization.NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone();
ninfo1.NumberGroupSizes = new Int32[] { 3 };//整数部は3桁区切り
ic.NumberFormat = ninfo1;
// 編集時の書式設定
System.Globalization.NumberFormatInfo ninfo2 = (System.Globalization.NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone();
ninfo2.NumberGroupSizes = new Int32[] { 0 };//桁区切りなし
ic.EditMode.NumberFormat = ninfo2;
FpSpread1.Sheets[0].Columns[0].CellType = ic;//セル型を1列目に設定
FpSpread1.Sheets[0].Cells[0, 0].Value = 1000;
}
{
if (IsPostBack)
{
return;
}
// 整数型セルの設定
FarPoint.Web.Spread.IntegerCellType ic = new FarPoint.Web.Spread.IntegerCellType();
// 表示時の書式設定
System.Globalization.NumberFormatInfo ninfo1 = (System.Globalization.NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone();
ninfo1.NumberGroupSizes = new Int32[] { 3 };//整数部は3桁区切り
ic.NumberFormat = ninfo1;
// 編集時の書式設定
System.Globalization.NumberFormatInfo ninfo2 = (System.Globalization.NumberFormatInfo)System.Globalization.CultureInfo.CurrentCulture.NumberFormat.Clone();
ninfo2.NumberGroupSizes = new Int32[] { 0 };//桁区切りなし
ic.EditMode.NumberFormat = ninfo2;
FpSpread1.Sheets[0].Columns[0].CellType = ic;//セル型を1列目に設定
FpSpread1.Sheets[0].Cells[0, 0].Value = 1000;
}
旧文書番号
40239