PowerTools InputMan for Windows Forms 8.0J
DefaultActiveField プロパティ (GcMask)
使用例 

既定のアクティブフィールドを取得または設定します。
構文
Public Property DefaultActiveField As MaskField
public MaskField DefaultActiveField {get; set;}

プロパティ値

フィールドを表すMaskFieldオブジェクト。 既定値はNothingです。
例外
例外解説
System.ArithmeticException 指定されたフィールドがFieldCollectionに存在しません。
解説
コントロールがフォーカスを取得したときは既定のアクティブフィールドにキャレットが移されます。
使用例
入力を自動変換しない GcMask コントロールを作成するコード例を次に示します。この例では他に AutoConvert、 DefaultActiveField と Fields プロパティを使用して、特定の文字の入力を許可する GcMask コントロールを作成しています。
//  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
参照

GcMask クラス
GcMask メンバ

 

 


© 2004-2015 GrapeCity inc. All rights reserved.