入力する文字数をバイト単位で制限する方法はありますか?
対象製品
SPREAD for Windows Forms 8.0J
詳細
GcTextBox型セルのMaxLengthUnitプロパティをByteに設定することで、入力する文字数をバイト単位で制限することができます。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' GcTextBox型セルの設定
Dim gctxt As New GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType()
gctxt.MaxLength = 4
' MaxLengthの単位をバイトに設定
gctxt.MaxLengthUnit = GrapeCity.Win.Spread.InputMan.CellType.LengthUnit.Byte
FpSpread1.ActiveSheet.Columns(0).CellType = gctxt
End Sub
' GcTextBox型セルの設定
Dim gctxt As New GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType()
gctxt.MaxLength = 4
' MaxLengthの単位をバイトに設定
gctxt.MaxLengthUnit = GrapeCity.Win.Spread.InputMan.CellType.LengthUnit.Byte
FpSpread1.ActiveSheet.Columns(0).CellType = gctxt
End Sub
◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
// GcTextBox型セルの設定
GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType gctxt = new GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType();
gctxt.MaxLength = 4;
// MaxLengthの単位をバイトに設定
gctxt.MaxLengthUnit = GrapeCity.Win.Spread.InputMan.CellType.LengthUnit.Byte;
fpSpread1.ActiveSheet.Columns[0].CellType = gctxt;
}
{
// GcTextBox型セルの設定
GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType gctxt = new GrapeCity.Win.Spread.InputMan.CellType.GcTextBoxCellType();
gctxt.MaxLength = 4;
// MaxLengthの単位をバイトに設定
gctxt.MaxLengthUnit = GrapeCity.Win.Spread.InputMan.CellType.LengthUnit.Byte;
fpSpread1.ActiveSheet.Columns[0].CellType = gctxt;
}
キーワード
セル型