Basic Library for WPF and Silverlight | ComponentOne
WPF and Silverlight Edition Basic Library / Masked Text Box / MaskedTextBox Quick Start / Step 3 of 4: Adding Code to the Application
In This Topic
    Step 3 of 4: Adding Code to the Application
    In This Topic

    In the previous steps you set up the application's user interface and added controls to your application. In this step you'll add code to your application to finalize it.

    Complete the following steps:

    1. In Design view, double-click C1MaskedTextBox1 to switch to Code view and create the C1MaskedTextBox1_TextChanged event handler. Return to Design view and repeat this step with each of the C1MaskedTextBox controls so that they each have a C1MaskedTextBox1_TextChanged event handler.
    2. In Code view, add the following import statement to the top of the page:
    Visual Basic
    Copy Code
    Imports C1.WPF
    OR
    Imports C1.Silverlight
    

     

    C#
    Copy Code
    using C1.WPF;
    OR
    using C1.Silverlight;
    
    1. Add code to the C1MaskedTextBox1_TextChanged event handler so that it appears like the following:
    Visual Basic
    Copy Code
    Private Sub C1MaskedTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles C1MaskedTextBox1.TextChanged
        Me.Label2.Content = "Mask: " & Me.C1MaskedTextBox1.Mask & "  Value: " & Me.C1MaskedTextBox1.Value & "  Text: " & Me.C1MaskedTextBox1.Text
    End Sub
    

     

    C#
    Copy Code
    private void c1mtb1_TextChanged(object sender, TextChangedEventArgs e)
    {
        this.lbl2.Content = "Mask: " + this.c1mtb1.Mask + " Value: " + this.c1mtb1.Value + " Text: " + this.c1mtb1.Text;
    }
    
    1. Add code to the C1MaskedTextBox2_TextChanged event handler so that it appears like the following:
    Visual Basic
    Copy Code
    Private Sub C1MaskedTextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles C1MaskedTextBox2.TextChanged
        Me.Label3.Content = "Mask: " & Me.C1MaskedTextBox2.Mask & "  Value: " & Me.C1MaskedTextBox2.Value & "  Text: " & Me.C1MaskedTextBox2.Text
    End Sub
    

     

    C#
    Copy Code
    private void c1MaskedTextBox2_TextChanged(object sender, TextChangedEventArgs e)
    {
        this.label3.Content = "Mask: " + this.c1MaskedTextBox2.Mask + " Value: " + this.c1MaskedTextBox2.Value + " Text: " + this.c1MaskedTextBox2.Text;
    }
    
    1. Add code to the C1MaskedTextBox3_TextChanged event handler so that it appears like the following:
    Visual Basic
    Copy Code
    Private Sub C1MaskedTextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles C1MaskedTextBox3.TextChanged
        Me.Label4.Content = "Mask: " & Me.C1MaskedTextBox3.Mask & "  Value: " & Me.C1MaskedTextBox3.Value & "  Text: " & Me.C1MaskedTextBox3.Text
    End Sub
    

     

    C#
    Copy Code
    private void c1MaskedTextBox3_TextChanged(object sender, TextChangedEventArgs e)
    {
        this.label4.Content = "Mask: " + this.c1MaskedTextBox3.Mask + " Value: " + this.c1MaskedTextBox3.Value + " Text: " + this.c1MaskedTextBox3.Text;
    }
    
    1. Add code to the C1MaskedTextBox4_TextChanged event handler so that it appears like the following:
    Visual Basic
    Copy Code
    Private Sub C1MaskedTextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles C1MaskedTextBox4.TextChanged
        Me.Label5.Content = "Mask: " & Me.C1MaskedTextBox4.Mask & "  Value: " & Me.C1MaskedTextBox4.Value & "  Text: " & Me.C1MaskedTextBox4.Text
    End Sub
    

     

    C#
    Copy Code
    private void c1MaskedTextBox4_TextChanged(object sender, TextChangedEventArgs e)
    {
        this.label5.Content = "Mask: " + this.c1MaskedTextBox4.Mask + " Value: " + this.c1MaskedTextBox4.Value + " Text: " + this.c1MaskedTextBox4.Text;
    }
    

    In this step you completed adding code to your application. In the next step you'll run the application and observe run-time interactions.