HI All:
I am currently implementing a TextBox to allow user to type the
things the user wants to search. The actual search routine is
happening on Textbox Validated event. My user wants me trap enter
key in the Search TextBox, so that after the user complete their
search string. The user can either press enter key or shift the
focus to next control. The problem I am facing I cannot easily find
out what is my next tab control on my win form. I have to write
small routine to search for. I just want to know is there anyone in
this newsgroup has better solution.
....
private void textBox1_KeyPress(object
sender,System.Windows.Forms.KeyPressEventArgs e) {
if (e.KeyChar == '\r')
{
Control ctr = FindNextTabControl
(this.textBox1.TabIndex + 1);
ctr.Focus(); // to triggle validated event to
perform the search
}
}
private Control FindNextTabControl(int TabIndex)
{
Control retCtr = null;
foreach(Control ctr in this.Controls)
{
if (ctr.TabIndex == TabIndex)
{
retCtr = ctr;
break;
}
else if (ctr.TabIndex == 0)
retCtr = ctr;
}
return retCtr;
}
private void textBox1_Validated(object sender,
System.EventArgs e)
{
//actual search here
}
....
Thanks in Advance
DK