0

Hi all,
I'm trying to capture an event when tab is pressed in a textbox using visual studio.net, and am having a hard time. I can capture anything else, inluding the keys that are difficult like instert, alt, and the arrow keys. Here is the MSDN page that did not help: http://msdn.microsoft.com/en-us/library/system.windows.forms.keypresseventargs.keychar.aspx.

I have set up breakpoint for keyup, keydown, keypress, and leave events, but the tab key does not set them off. I capture the enter key this way:

void textBox1_KeyPress( Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e )
   {
		if(e->KeyChar == '\r')
			MessageBox::Show("enter key pressed");
   }

Thanks in advance.

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by tonymuilenburg
1

Do you have the AcceptsTab property of the textbox set to true?

I was able to get it using

private: System::Void textBox1_KeyDown(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e) {
	if(e->KeyCode == Keys::Tab)
		 MessageBox::Show("Tabbed!");
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.