Reputation: 40
My Masked Text Box Mask is :
000/000
I want to display the value of a textbox1 to the first half of the mask and textbox2 value to the other half.
textbox1/ textbox2
How to do this ?
Upvotes: 0
Views: 437
Reputation: 10765
You are probably going to have to create a function which does the string concatenation and places the value inside your masked textbox
, you'll need to wire this up to each Textbox.TextChanged
event
so that when the user types a new character, the Text
property of the masked textbox
gets updated:
//Text changed event for textBox1
private void textBox1_TextChanged(object sender, RoutedEventArgs e)
{
//If null set to empty
textBox1.Text = textBox1.Text ?? "";
SetMaskedTextbox();
}
//Text changed event for textBox2
private void textBox2_TextChanged(object sender, RoutedEventArgs e)
{
//If null set to empty
textBox2.Text = textBox2.Text ?? "";
SetMaskedTextbox();
}
private void SetMaskedTextbox()
{
//Just concatenate the textbox values with the "/" and set it to the masked textbox .Text
maskedTextbox.Text = textBox1.Text + "/" + textBox2.Text;
}
Upvotes: 1