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.

Recommended Answers

All 2 Replies

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)

Hey, the acceptstab was all that was needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.