Hi,
I have specified shotcuts on button tool. I have used the same tool in Context Poup menu and Application menu. I have set the property
tool.SharedProps.Shortcut. This add a text in tooltip title e.g Button1Title(Ctrl+D). This is fine. When i use the tool in Context menu it shows the (Ctrl + D) in front of it. I want to hide showing of showcut on tool when used in context menu.
Same thing applies for Application Menu tools.
Sumit Kute
I know this is a late post, but this is my solution. Add the following class to your project and then use it within your main form as demonstrated. You will require an UltraToolbarsManager object on the main form with various popup menus; simply replace the string MYKEY with the key of one of the menus you want as both a main menu item and popup menu item. Sorry about the lack of comments in the code, but I'm sure you'll work it out.
In your main form:
Private _PopupMenuManager As PopupMenuShortCutVisibilityManager
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _PopupMenuManager = New PopupMenuShortCutVisibilityManager(UltraToolbarsManager1) _PopupMenuManager.AddMenuKey("MYKEY")End Sub
The PopupMenuShortCutVisibilityManager class:
Imports Infragistics.Win.UltraWinToolbars
Public Class PopupMenuShortCutVisibilityManager
Private Enum Visibility As Short Show HideEnd Enum
Private _MenuSettings As New HashtablePrivate _PopupMenuKeys As New List(Of String)Private WithEvents _Toolbar As UltraToolbarsManager = Nothing
Public Sub New(ByVal toolbar As UltraToolbarsManager) If toolbar Is Nothing Then Throw New ArgumentNullException("Toolbar Manager argument may not be null") _Toolbar = toolbarEnd Sub
Private Sub _Toolbar_AfterToolCloseup(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.ToolDropdownEventArgs) Handles _Toolbar.AfterToolCloseup If _PopupMenuKeys.Contains(e.Tool.Key) AndAlso e.Tool.IsRootTool Then ToggleShortCutVisibility(e.Tool.Key, e.Tool, Visibility.Show) End IfEnd Sub
Private Sub _Toolbar_BeforeToolDropdown(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinToolbars.BeforeToolDropdownEventArgs) Handles _Toolbar.BeforeToolDropdown If _PopupMenuKeys.Contains(e.Tool.Key) AndAlso e.Tool.IsRootTool Then ToggleShortCutVisibility(e.Tool.Key, e.Tool, Visibility.Hide) End IfEnd Sub
Public Sub AddMenuKey(ByVal key As String)Try If Not _PopupMenuKeys.Contains(key) Then If TypeOf _Toolbar.Tools(key) Is PopupMenuTool Then Dim menu As PopupMenuTool = _Toolbar.Tools(key) AddMenuKey(key, menu) _PopupMenuKeys.Add(key) Else Throw New Exception("Only PopupMenuTool type tools can be added") End If Else Throw New Exception(String.Format("Key '{0}' has already been added")) End IfCatch ex As Exception Throw New Exception(String.Format("{0}.AddMenuKey Error", Me.GetType.Name), ex)End TryEnd Sub
Private Sub AddMenuKey(ByVal baseKey As String, ByVal menu As PopupMenuTool) Dim toolKey As String = String.Empty For Each tool As ToolBase In menu.Tools toolKey = String.Format("{0}.{1}", baseKey, tool.Key) SetMenuKey(toolKey, tool) If TypeOf tool Is PopupMenuTool Then AddMenuKey(tool.Key, tool) End If NextEnd Sub
Private Sub SetMenuKey(ByVal toolKey As String, ByVal tool As ToolBase) If tool.SharedProps.Shortcut <> Shortcut.None Then If Not _MenuSettings.ContainsKey(toolKey) Then _MenuSettings.Add(toolKey, tool.SharedProps.Shortcut) End If End IfEnd Sub
Private Sub SetShortCutVisibility(ByVal toolKey As String, ByVal tool As ToolBase, ByVal visibility As Visibility) If _MenuSettings.ContainsKey(toolKey) Then If visibility = PopupMenuShortCutVisibilityManager.Visibility.Hide Then tool.SharedProps.Shortcut = Shortcut.None Else tool.SharedProps.Shortcut = CType(_MenuSettings(toolKey), System.Windows.Forms.Shortcut) End If End IfEnd Sub
Private Sub ToggleShortCutVisibility(ByVal baseKey As String, ByVal menu As PopupMenuTool, ByVal visibility As Visibility) Dim toolKey As String = String.Empty For Each tool As ToolBase In menu.Tools toolKey = String.Format("{0}.{1}", baseKey, tool.Key) SetShortCutVisibility(toolKey, tool, visibility) If TypeOf tool Is PopupMenuTool Then ToggleShortCutVisibility(toolKey, tool, visibility) End If NextEnd Sub
There is no public way to remove this shortcut. You could try to use a creation filter, but there will be empty space where the shortcut was. You can submit a feature request for the ability to hide the shortcut here: http://devcenter.infragistics.com/Protected/RequestFeature.aspx.