Needbass2004 Posted September 30, 2004 Posted September 30, 2004 Ok, I know it can be easily done. Want I want is to make a custom Textbox control...Because I like making my apps customized. I need to be able to capture the keystrokes once my control is clicked on. I also need to know the values of Enter, Backspace, and Escape, so that it edits like the normal textbox. I don't want it to capture all keystrokes globally, because that wouldn't be very professional if someone clicked my textbox then hit another window and typed. I am using GDI+ to do the textbox in layers. Bottom layer will be a background 2nd Layer will the text 3rd layer will be the 'GLASS' looking highlights that will look cool. Thanks. Quote
Leaders Iceplug Posted September 30, 2004 Leaders Posted September 30, 2004 So, unless I'm missing something, you can use the KeyPress and KeyDown event to check when a key is pressed. Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
TamuTamu Posted October 4, 2004 Posted October 4, 2004 Additonally if you use the KeyDown or KeyUp event check to see what the key is, is simple by using the Keys enumerable. private void TextBox1_KeyUp(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { MessageBox.Show("You pressed enter"); } } KeyPress is useful to allow only letters or numbers for example. private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if(!Char.IsControl(e.KeyChar) && !Char.IsNumber(e.KeyChar)) { e.Handled = true; } } The code above will not allow anything that isn't a control (ENTER, ESCAPE, CTRL etc or a number) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.