サロゲート文字の入力を禁止するには?
対象製品
MultiRow for Windows Forms 7.0J
詳細
TextBoxCellの編集には標準の TextBox(System.Windows.Form.TextBox)を提供しているため、サロゲート文字(サロゲートペア)の入力を直接禁止することはできません。次のように入力された文字に対して、検証を行うことで値の確定を禁止できます。
Visual Basic
C#
InputManCell の GcTextBoxCell を使用すると、サロゲート文字の入力を直接禁止できます。この場合、GcTextBoxCell.Format プロパティに "^T" を指定します。
Visual Basic
C#
参考:
InputManCellのGcTextBoxCellを使用すると、数字やカナ、アルファベットや記号などのほかに、以下の文字に対して入力を制限することができます。
文字の入力制限は、GcTextBoxCell.Formatプロパティに該当するキーワードを設定することで実現します。
Visual Basic
Imports GrapeCity.Win.MultiRow
Dim textBoxCell1 As New TextBoxCell()
Dim surrogateCharValidator1 As New SurrogateCharValidator()
surrogateCharValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(surrogateCharValidator1)
gcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { textBoxCell1 })
Dim textBoxCell1 As New TextBoxCell()
Dim surrogateCharValidator1 As New SurrogateCharValidator()
surrogateCharValidator1.Actions.Add(New LineNotify())
textBoxCell1.Validators.Add(surrogateCharValidator1)
gcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { textBoxCell1 })
C#
using GrapeCity.Win.MultiRow;
TextBoxCell textBoxCell1 = new TextBoxCell();
SurrogateCharValidator surrogateCharValidator1 = new SurrogateCharValidator();
surrogateCharValidator1.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(surrogateCharValidator1);
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { textBoxCell1 });
TextBoxCell textBoxCell1 = new TextBoxCell();
SurrogateCharValidator surrogateCharValidator1 = new SurrogateCharValidator();
surrogateCharValidator1.Actions.Add(new LineNotify());
textBoxCell1.Validators.Add(surrogateCharValidator1);
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { textBoxCell1 });
InputManCell の GcTextBoxCell を使用すると、サロゲート文字の入力を直接禁止できます。この場合、GcTextBoxCell.Format プロパティに "^T" を指定します。
Visual Basic
Imports GrapeCity.Win.MultiRow
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim gcTextBoxCell1 As New InputManCell.GcTextBoxCell
gcTextBoxCell1.Name = "gcTextBoxCell1"
gcTextBoxCell1.Format = "^T"; ' サロゲート文字以外の入力を許可
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { gcTextBoxCell1 })
Imports InputManCell = GrapeCity.Win.MultiRow.InputMan
Dim gcTextBoxCell1 As New InputManCell.GcTextBoxCell
gcTextBoxCell1.Name = "gcTextBoxCell1"
gcTextBoxCell1.Format = "^T"; ' サロゲート文字以外の入力を許可
GcMultiRow1.Template = Template.CreateGridTemplate(New Cell() { gcTextBoxCell1 })
C#
using GrapeCity.Win.MultiRow;
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcTextBoxCell gcTextBoxCell1 = new InputManCell.GcTextBoxCell();
gcTextBoxCell1.Name = "gcTextBoxCell1";
gcTextBoxCell1.Format = "^T"; // サロゲート文字以外の入力を許可
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcTextBoxCell1 });
using InputManCell = GrapeCity.Win.MultiRow.InputMan;
InputManCell.GcTextBoxCell gcTextBoxCell1 = new InputManCell.GcTextBoxCell();
gcTextBoxCell1.Name = "gcTextBoxCell1";
gcTextBoxCell1.Format = "^T"; // サロゲート文字以外の入力を許可
gcMultiRow1.Template = Template.CreateGridTemplate(new Cell[] { gcTextBoxCell1 });
参考:
InputManCellのGcTextBoxCellを使用すると、数字やカナ、アルファベットや記号などのほかに、以下の文字に対して入力を制限することができます。
文字の入力制限は、GcTextBoxCell.Formatプロパティに該当するキーワードを設定することで実現します。
- サロゲート ペア文字
- 2バイト文字(サロゲート ペア文字を除いた全角文字)
- JIS X 0208で構成された文字
- Shift JIS(CP932)で構成された文字
- IVS(Ideographic Variation Sequence)文字