c# - How to move the textbox caret to the right -


I would like to change all the characters entered in the text box in the upper case. Code will add character, but how can I get the correct direction?

  Private Zero Text box3_keyPress (Object Sender, KeyPressEventArgs E) {textBox3.Text = = e.KeyChar.ToString (). ToUpper (); E.Handled = True; }    

text box to above ; You do not need to manually process it.

Note that textbox3.Text + = e.KeyChar.ToString (). ToUpper (); The new character ends at the end of the string even if the input is in the middle of the carat string (which means that most users will be highly misleading). For this reason we can not assume that after inputting the character, the input carpet should appear at the end of the string.

If you still want to do this in the code, then you should do something like this:

  // is required for backspace and for working in this way (Char.IsControl (e.KeyChar)) {return; } Int selStart = textbox3.SelectionStart; String = first text box 3 Lesson Shuttle (0, selStart); After the string = textbox3.Text.Substring (before.Length); TextBox3.Text = string.Concat (before, E.K.K. toString (.) ToUpper (), after); Textbox3.SelectionStart = before.Length + 1; E.Handled = True;  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -