Answer the question
In order to leave comments, you need to log in
When adding words to a TextBox via code, the caret is not moved to the end of the phrase. Where is the mistake?
On my form, there are 2 TextBox fields in which I want to make the date input as follows: the user enters the first digits, then a dot is put (through code, not by the user), enters two numbers again, dot again.
public void textBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (((TextBox)sender).Text.Length == 2 || ((TextBox)sender).Text.Length == 5)
{
((TextBox)sender).Text += ".";
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question