Hi,
how do you programtically click a button on a Toolbar ?
Thanks
Michael
I think the best thing to do here would be to separate out the click event handler code for this one tool into its own method which is called from the normal ToolClick event handler. Then you can call that method from anywhere else in your code and simulate the button's click action without having to interact with the toolbars manager.
Hi Mike,
suppose to have a toolbar that composes itself at runtime and a specific place could be occupied by two (or more) different ButtonTools. In this case you can not know what code to execute, it depends on what ButtonTool has been used. So, please could you demonstrate me how to invoke the click programmatically?
Thanks in advance Gianni
I have the same problem
If tlbPulsanti.Tools.Exists(sTool) Then tlbTool = tlbPulsanti.Tools(sTool) If tlbTool.EnabledResolved Then If tlbTool.GetType Is GetType(ButtonTool) Then DirectCast(tlbTool , ButtonTool) ..... Click
I dont'know sTool value but i must invoke the click programmatically.In UltraGrid there is PerformAction(UltraGridAction)
Lorenzo
Have you tried what was described at the top of the thread (creating a method to handle the button click logic and call it both from the UltraToolbarsManager.ToolClick event handler and the place where you need to invoke the click programmatically)? That is the best way to implement this.
It isn't possible. The button tools are dinamically created in a dll from a configuration file. Each user chooses the menu to emulate from button.
I solved in this (terrible) way:
tlbTool = Me.Tools(sTool)With DirectCast(tlbTool, ButtonTool) Dim aAppearanceData As Infragistics.Win.AppearanceData = Nothing With .SharedProps.ToolInstances(0) .ResolveAppearance(aAppearanceData, Infragistics.Win.AppearancePropFlags.BackColor) Dim srt As Shortcut = .SharedProps.Shortcut .SharedProps.Shortcut = Shortcut.Ctrl0 SendKeys.Send("^0") Application.DoEvents() .SharedProps.Shortcut = srt .SharedProps.AppearancesSmall.AppearanceOnMenu.BackColor = aAppearanceData.BackColor End With aAppearanceData = Nothing End With
Currently there is no way to programmatically click a tool. You can submit a feature request for this.
You can add ToolButton->SharedProps->Shortcut (eg: F8) then, in the code:
SendKeys.Send("{F8}");