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.
精彩评论