GrapeCity.Win.Editors.v80 アセンブリ > GrapeCity.Win.Editors 名前空間 > GcMask クラス : AutoConvert プロパティ |
値 | 説明 |
---|---|
True | 文字を自動変換します。 |
False | 文字の自動変換をしません。 |
AutoConvert プロパティをTrueに設定すると、変換可能な文字はすべて 入力マスクに従って自動的に変換されます。 たとえば入力マスクが"A"に設定されていると、小文字を入力しても自動的に大文字に変換されます。 また、全角文字だけが許可されている場合は、入力された半角文字は全角文字に変換されます。
以下にAutoConvert プロパティの設定によってコントロール内部で行われる自動変換の手順を示します。
半角カタカナ、全角カタカナ、およびひらがなは、次のように変換されます。
AutoConvert プロパティをFalseに設定すると、入力マスクの範囲外の文字が入力された場合は InvalidInput イベントが発生します。
// Please use the following namespace // using System.Windows.Forms; // using GrapeCity.Win.Editors; public void SetFieldsSettings() { // Creates an instance of a GcMask control. GcMask gcMask1 = new GcMask(); // Creates some fields. GrapeCity.Win.Editors.Fields.MaskLiteralField maskLiteralField1 = new GrapeCity.Win.Editors.Fields.MaskLiteralField(); GrapeCity.Win.Editors.Fields.MaskPatternField maskPatternField1 = new GrapeCity.Win.Editors.Fields.MaskPatternField(); GrapeCity.Win.Editors.Fields.MaskLiteralField maskLiteralField2 = new GrapeCity.Win.Editors.Fields.MaskLiteralField(); GrapeCity.Win.Editors.Fields.MaskPatternField maskPatternField2 = new GrapeCity.Win.Editors.Fields.MaskPatternField(); // Sets the fields' settings. maskLiteralField1.Text = "TEL:"; maskPatternField1.MaxLength = 4; maskPatternField1.MinLength = 4; maskPatternField1.Pattern = "\\D"; maskLiteralField2.Text = "-"; maskPatternField2.MaxLength = 4; maskPatternField2.MinLength = 4; maskPatternField2.Pattern = "\\D"; // Adds fields to the GcMask control. gcMask1.Fields.AddRange(new GrapeCity.Win.Editors.Fields.MaskField[] { maskLiteralField1, maskPatternField1, maskLiteralField2, maskPatternField2}); // Sets the AutoConvert to false in order to not accept invalid chars. gcMask1.AutoConvert = false; // Sets the DefaultActiveField to the first pattern field for inputing. gcMask1.DefaultActiveField = maskPatternField1; } // // This method is equivalent to the method "SetFieldsSettings()" above. // public void SetFieldsByPatternString() { GcMask gcMask1 = new GcMask(); // Create fields by pattern string. gcMask1.Fields.AddRange(@"TEL\D{4}-\D{4}"); // Sets the AutoConvert to false in order to not accept invalid chars. gcMask1.AutoConvert = false; // Sets the first MaskPatternField instance as the default active field. gcMask1.DefaultActiveField = gcMask1.Fields.Find<GrapeCity.Win.Editors.Fields.MaskPatternField>(); }
' Please use the following namespace ' Imports System.Windows.Forms; ' Imports GrapeCity.Win.Editors; Public Sub SetFieldsSettings() ' Creates an instance of a GcMask control. Dim gcMask1 As New GcMask() ' Creates some fields. Dim maskLiteralField1 As New GrapeCity.Win.Editors.Fields.MaskLiteralField() Dim maskPatternField1 As New GrapeCity.Win.Editors.Fields.MaskPatternField() Dim maskLiteralField2 As New GrapeCity.Win.Editors.Fields.MaskLiteralField() Dim maskPatternField2 As New GrapeCity.Win.Editors.Fields.MaskPatternField() ' Sets the fields' settings. maskLiteralField1.Text = "TEL:" maskPatternField1.MaxLength = 4 maskPatternField1.MinLength = 4 maskPatternField1.Pattern = "\D" maskLiteralField2.Text = "-" maskPatternField2.MaxLength = 4 maskPatternField2.MinLength = 4 maskPatternField2.Pattern = "\D" ' Adds fields to the GcMask control. gcMask1.Fields.AddRange(New GrapeCity.Win.Editors.Fields.MaskField() {maskLiteralField1, maskPatternField1, maskLiteralField2, maskPatternField2}) ' Sets the AutoConvert to false in order to not accept invalid chars. gcMask1.AutoConvert = False ' Sets the DefaultActiveField to the first pattern field for inputing. gcMask1.DefaultActiveField = maskPatternField1 End Sub ' ' This method is equivalent to the method "SetFieldsSettings()" above. ' Public Sub SetFieldsByPatternString() Dim gcMask1 As New GcMask() ' Create fields by pattern string. gcMask1.Fields.AddRange("TEL\D{4}-\D{4}") ' Sets the AutoConvert to false in order to not accept invalid chars. gcMask1.AutoConvert = False ' Sets the first MaskPatternField instance as the default active field. gcMask1.DefaultActiveField = gcMask1.Fields.Find(Of GrapeCity.Win.Editors.Fields.MaskPatternField)() End Sub