バージョン

Sections プロパティ (XamMaskedEditor)

コントロールで使用されるセクションのコレクションです。マスクがもう解析された場合のみ有効なコレクションを返します。
シンタックス
'宣言
 
Public ReadOnly Property Sections As SectionsCollection
public SectionsCollection Sections {get;}
解説

マスクが解析されると、結果は SectionBase 派生オブジェクトのコレクションになります。このプロパティはそのコレクションを返します。各 SectionBase オブジェクトは、SectionBase.DisplayChars プロパティから返される表示文字のコレクションがあります。XamMaskedEditor も DisplayChars プロパティからすべてのセクションの集合表示文字を含むコレクションも公開します。

たとえば、解析されたマスクの構造を問い合わせて確認したい場合や、セクションまたは表示文字ベースで現在のユーザー入力を問い合わせたり操作する場合にこのプロパティは役に立ちます。

使用例
Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.maskedEditor1.StartEditMode()

        Me.maskedEditor1.Mask = "###-aaa"
        Me.maskedEditor1.Value = "123-XYZ"

        Dim sections As SectionsCollection = Me.maskedEditor1.Sections

        ' The follwing will print out sections. Sections are based on the 
        ' mask. The mask we set above has two edit sections and one 
        ' literal section.
        Debug.WriteLine("Sections: ")
        Debug.WriteLine("Sections(0) = " & sections(0).GetType().Name)
        Debug.WriteLine("Sections(1) = " & sections(1).GetType().Name)
        Debug.WriteLine("Sections(2) = " & sections(2).GetType().Name)

        ' Like sections, display characters are also based on mask.
        ' The following will print out all the display characters.
        ' It will print out the type of each display character and the
        ' character value associated with the display character (which
        ' comes from the Value that we set above).
        Debug.WriteLine("DisplayChars: ")
        Dim displayChars As DisplayCharsCollection = Me.maskedEditor1.DisplayChars
        Dim i As Integer
        For i = 0 To displayChars.Count - 1
            Dim dc As DisplayCharBase = displayChars(i)
            Debug.WriteLine("DisplayChars(" & i & ") = " & dc.GetType().Name & " '" & dc.Char & "'")
        Next
    End Sub
public void button1_Click( object sender, RoutedEventArgs e )
{
	this.maskedEditor1.StartEditMode( );

	this.maskedEditor1.Mask = "###-aaa";
	this.maskedEditor1.Value = "123-XYZ";

	SectionsCollection sections = this.maskedEditor1.Sections;

	// The follwing will print out sections. Sections are based on the 
	// mask. The mask we set above has two edit sections and one 
	// literal section.
	Debug.WriteLine( "Sections: " );
	Debug.WriteLine( "Sections[0] = " + sections[0].GetType( ).Name );
	Debug.WriteLine( "Sections[1] = " + sections[1].GetType( ).Name );
	Debug.WriteLine( "Sections[2] = " + sections[2].GetType( ).Name );

	// Like sections, display characters are also based on mask.
	// The following will print out all the display characters.
	// It will print out the type of each display character and the
	// character value associated with the display character (which
	// comes from the Value that we set above).
	Debug.WriteLine( "DisplayChars: " );
	DisplayCharsCollection displayChars = this.maskedEditor1.DisplayChars;
	for ( int i = 0; i < displayChars.Count; i++ )
	{
		DisplayCharBase dc = displayChars[i];
		Debug.WriteLine( "DisplayChars[" + i + "] = " + dc.GetType( ).Name + " '" + dc.Char + "'" );
	}
}
参照