入力する文字数をバイト単位で制限する方法はありますか?
対象製品
SPREAD for Windows Forms 7.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;
}
関連情報
- 特定文字の入力のみを許可するには
- 【テキスト型セル】 全ての半角文字(英数、カナ)の入力だけを許可することは出来ますか?
- JIS X 0213で追加された文字や環境依存文字、あるいは絵文字の入力を制限できますか?
キーワード
「入力制限」