I apologize if I am missing something here, but it looks like there is a single event handler for all clicks on all tools for all ultratoolbars on a form. Is this right? So I place an UltraToolBarManager control on my form, add a menu bar and a toolbar, add some menus and buttons, and then I have a giant select case statement to handle the clicks inside the UltraToolBarManager.ToolClick event handler:
Select Case e.Tool.Key
Case "Save"
(etc...)
Please advise if there is something I am missing or if there is a way to set up single event handlers for the individual tools. I am using NetAdvantage 2007 vol 3.
Thanks,
Bob
Thanks! Works in VS2005 as well.
I created this code with VS2008. Type "sub new()" and hit the Enter key and the editor will automatically create the VS2003 initialization code.
First of all thanks for the help. The problem with your example is that it is based on vb.net 2003 code. The addhandler line from the code snippet would have to be moved to the Form_Load event in vb.net 2005.
It is possible to hook individual tool events in VB without creating a member variable, it just needs to be done manually and without the 'Handles' keyword. Here is some form code that will accomplish this:
Sub New()
' This call is required by the Windows Form Designer. InitializeComponent()
' Add any initialization after the InitializeComponent() call.
AddHandler toolBarManager.Toolbars("toolBar").Tools("Save").ToolClick, AddressOf btnSave_Click
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) End Sub
No that doesn't work - at least not in vb.net. If you set up an event handler for a toolclick event, the only thing you can access is the events for the toolbar manager itself. For example this is NOT valid
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles toolBarManager.Toolbars("toolBar").Tools("Save").ToolClick
The only way I figured out to set up individual event handlers was to create a reference to the individual tools in the code (using withevents) and then make the event handlers that way. You may have meant that in your post:
Protected WithEvents btnSave As ButtonTool = toolBarManager.Toolbars("toolBar").Tools("Save")
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolClickEventArgs) Handles btnSave.ToolClick