开发者

Selecting button in Winform ToolStrip

开发者 https://www.devze.com 2023-02-22 21:07 出处:网络
Reference Image I want to select a button(\"Exit\") on the ToolStrip after pressing a button (\"ButtonFocus To Exit\") outside the toolstrip.

Selecting button in Winform ToolStrip

Reference Image

I want to select a button("Exit") on the ToolStrip after pressing a button ("ButtonFocus To Exit") outside the toolstrip.

I used ExitToolStripButton.Select() on ButtonFocusToExit.Click but which seems like its selecting the button ("Exit") but when i pressed enter it never execute the code in "ExitToolStripButton_Click"开发者_如何学JAVA .

So the button is still not active. Can anyone have fix to it?


Got the solution ...

First focus on the ToolStrip and then Select the Control on the Toolstrip

ToolStrip1.Focus()

ExitToolStripButton.Select()


Check if event is missing the event handler

Select the ExitToolStripButton > go to properties > events tab> Click Event > select the ExitToolStripButton_Click


You want to execute the ExitToolStripButton codebehind? You can call ExitToolStripButton.PerformClick();


Make sure it has focus. Are you sure the function you are using actually give the object focus? It could just give it the appearance of selection.

According to MSDN:

Select  |  Selects the item. (inherited from ToolStripItem)

It doesn't say anything about focusing it.

0

精彩评论

暂无评论...
验证码 换一张
取 消