Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
How do I programmatically call a button press?
posted

In VB.NET, I can programmatically call a button press by typing something along these lines:

 CloseCommButton_Click(sender, e)

Now, I have a separate function that handles button clicks: 

Private Sub UltraToolbarsManager1_ToolClick(sender As Object, e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles UltraToolbarsManager1.ToolClick

Case "CloseCommButton"
     HandleOpenCommButton()

End Select

I would like to create a function that will pass "CloseCommButton" to the UltraToolbarsManager1_ToolClick function but in order to do this, I need to provide it with an objects and a toolclickeventargs.  Since I'm calling it from a function, I don't know what to send it.  I've tried something along the lines of:

dim sender as object

dim e as toolclickevents

Dim e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs = "CloseCommButton"

UltraToolbarsManager1_ToolClick(sender,e)

But this isn't working as I am being told that a string cannot be converted to Infragistics.Win.UltraWinToolbars.ToolClickEventArgs.  I'm stuck as to how to proceed from here and can't see to find another topic that discusses how to do this.  If you can help me with this, I'd appreciate it.  Thanks!

Parents
No Data
Reply
  • 2077
    Verified Answer
    Offline posted

    Hi Jeremy,

    You don't have to programatically call the button's click event handler. Just move the event handler's method body in a new method and call that instead. So when the toolbar button is clicked you can call the same method as it is called from the button's click event handler.

    When you are designing your toolbar you set the Key property on them. That property you have too check in the toolbarsManager_ToolClick event handler: e.Tool.Key.

    HTH,

    Emanuel

Children