Unable to set Focus on my CommandBar UserControl

Add-in Express™ Support Service
That's what is more important than anything else

Unable to set Focus on my CommandBar UserControl
 
Nicolas Bordeleau




Posts: 20
Joined: 2008-03-24
I added a Keyboard Shortcut, and I want to link it to a textbox (inside my UserControl) I added in the CommandBar. Keyboard Shortcut event work, but the problem is that I can't set the focus on the textbox of my UserControl. Either myTextBox.Focus() or myTextBox.Select() won't work. Any clue?

Thanks,
Nicolas

Posted 28 Mar, 2008 11:01:57 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Nicolas,

You need to use the ActiveInstance property. Please see the code below:

private void adxCommandBarButton1_Click(object sender)
{
	TextBox activeTextBox = adxCommandBarAdvancedControl1.ActiveInstance as TextBox;
	if (activeTextBox != null)
	activeTextBox.Focus();
}




Posted 28 Mar, 2008 11:12:45 Top