int index; private void toolStripButton1_Click(object sender, EventArgs e) { index = 1; Console.WriteLine("1111 1111111 111111"); SetFocus(); } private void toolStripButton2_Click(object sender, EventArgs e) { index = 2; MessageBox.Show("2"); SetFocus(); } private void toolStripButton3_Click(object sender, EventArgs e) { index = 3; MessageBox.Show("3"); SetFocus(); } private void SetFocus() { // Send key Tab and Right SendKeys.Send("{Tab}"); for (int i = 0; i < index - 1; i++) { SendKeys.Send("{Right}"); } }
Or
private void toolStripButton1_Click( object sender, EventArgs e ) { .... var b = (ToolStripButton)sender; BeginInvoke( new Action( () => b.Select() ) ); }