can any one help me to do this? i want to add to a ContextMenuStrip a tool of a UltraToolbarsManager, the text and the image is no a problem, but i cant add the event.
tnx
Dim miTool As Infragistics.Win.UltraWinToolbars.ToolBase = UltraToolbarsManager.Tools("any_key")
Dim mItem As ToolStripItem
mItem = ContextMenuStrip1.Items.Add(miTool.SharedProps.Caption, miTool.SharedProps.AppearancesSmall.Appearance.Image)
mItem.Enabled = tool.SharedProps.Enabled
'how to do this?
addhandler mItem.Click,addressof tool........
Use the ToolClick event of the WinToolbarsManager component in this circumstance. When handling this event, "e.Tool" will be the instance of the tool that was clicked to raise the event. In a typical implementation, you'd implement a "Select Case" statement (or "switch" in C#) to take different action based on the value of e.Tool.Key.
We recommend against directly handling the ToolClick event of the ToolBase instance itself.
tnx for your answer. in fact i actually do that. at this time a have the ToolClick event. i have the 'SELECT CASE' that you recommend me
----------------------------------------------------------------Select Case e.Tool.Key Case "btn_buscar" Dim frm As New busquedaPRODUCTO frm.MdiParent = Me frm.Show() e.Tool.SharedProps.Enabled = False Case "btn_costos" Dim frm As New costos frm.MdiParent = Me frm.Show()
.... and so on----------------------------------------------------------------
my application is finished, EXCEPT for one thing:
i need to add thes ribbon butons (all UltraToolbarsManager.Tools) to a windows.forms.ContextMenuStrip
i can add the image and the caption with this, (but i dont know how to add the event):
----------------------------------------------------------------Dim tool As Infragistics.Win.UltraWinToolbars.ToolBaseDim mItem As ToolStripItem
elMenu.Items.Clear()For Each str_key As String In llaves tool = utbm_toolbars.Tools(str_key) mItem = elMenu.Items.Add(tool.SharedProps.Caption, tool.SharedProps.AppearancesSmall.Appearance.Image) mItem.Enabled = tool.SharedProps.Enabled
'tool. 'AddHandler mItem.Click, AddressOf tool.ToolClickNext----------------------------------------------------------------
any idea?
I'm not entirely certain what you're asking here. Are you attempting to add new functionality to the ToolClick event of your WinToolbarsManager, or are you attempting to handle item click events on the item of the ContextMenuStrip?
Either way, I suggest that you encapsulate the functionality of each tool into its own method. For our ribbon, you'd use the ToolClick event of WinToolbarsManager to determine which tool was clicked, then to handle the ItemClick event (not ToolClick) of the ContextMenuStrip item to call the corresponding method for that item.
As another option, you could replace the ContextMenuStrip with another toolbar handled by WinToolbarsManager, to get context menu functionality. This will allow you to re-use the same tools, as well as the same ToolClick event.
" you'd use the ToolClick event of WinToolbarsManager to determine which tool was clicked, then to handle the ItemClick event (not ToolClick) of the ContextMenuStrip item to call the corresponding method for that item."
yes, that's what i tyed to do. but i cant. ok no problem your last answer (07-20-2009 10:24 AM) give me an idea:
- in the UltraToolbarsManager1_ToolClick event i call a function mySub(e.tool.key)
- in the ContextMenuStrip1_ItemClicked event i call the same function mySub(e.ClickedItem.Name)
- in the mySub function i use the select you recommend me
and that works. so tnx for your help. by the way i think your idea is better:
"As another option, you could replace the ContextMenuStrip with another toolbar handled by WinToolbarsManager, to get context menu functionality. This will allow you to re-use the same tools, as well as the same ToolClick event."
"re-use the same tools" thats what i was looking for. but i dont know how to handed them. ok no problem mySub is working fine
finally. thankyou very much for your time.