Home > Net >  How to capture keyboard input in textBox, including key combination.
How to capture keyboard input in textBox, including key combination.

Time:12-11

Just learn c #, want to capture the keyboard, the key combination stuck here, press CTRL + a, the result shows the CTRL + a, behind the letters are capitalized, according to a single button, display is a capital a lowercase, using the KeyDown event has occurred is not expected,
 private void textBox_KeyDown (object sender, KeyEventArgs e) 
{
Keystr="";
If (e.c. with our fabrication: ontrol)
{
if (! Keystr. The Contains (Ctrl + ""))
Keystr +="Ctrl +";
}

Keystr +=e.K eyCode. ToString ();

//MessageBox. Show (keystr);
TextBox. Text=keystr;
TextBox. Select (textBox Text Length, 0).//the cursor to the text finally
TextBox. ScrollToCaret ();//scroll to the cursor
}
  •  Tags:  
  • C#
  • Related