Search code examples
.netwinformscomboboxc++-clitoolstrip

Select ComboBox in Windows Forms ToolStrip


I have a problem focusing a ComboBox in a Windowsforms "ToolStrip" (C++ Cli).

I used the Designer to create a ToolStrip in my form and added a ComboBox (System.Windows.Forms.ToolStripComboBox) and it is visible and enabled.
When the form is loaded I want that Combobox to be selected, so I tried the following in the form-constructor.

this->CBox1->focus()

and

this->ToolStrip1->focus()  
this->CBox1->select()

none works.

Does anybody know how to make it work?


Solution

  • The ToolStripComboBox class contains a ComboBox property that enables you to access its embedded ComboBox control. This appears to work (C# code):

    this.Cbox1.ComboBox.Select();