문제

I have a context menu strip and it contains a combobox. And I want to set a default selected item for this combobox. I know get and set values for items in a context menu strip with a example as:

CtmAbc.Items(0).Text

But can't set selected item or add a event handler for this.

도움이 되었습니까?

해결책

Assuming your ComboBox index is 0, you can use the code below to set the selected item as the first item:

((contextMenuStrip1.Items[0]) as ToolStripComboBox).SelectedIndex = 0;

Or you can also access the ComboBox by key:

((contextMenuStrip1.Items["myComboBox"]) as ToolStripComboBox).SelectedIndex = 0;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top