Infragistics context menu not closing

414 views Asked by At

In my application i use Infragistics controls. Sometimes everything works perfectly, but sometimes context menu is not closing if clicked anywhere else. Example: 1) Right click on item 2) Click somewhere outside context menu 3) Context menu should close, but sometimes it stays open, until you click an item inside it.

Any ideas why this is happening?

Some code, how contextual menu is created and added to grid.

Dim contextualMenu As PopupMenuTool = New PopupMenuTool(key)
contextualMenu.DropDownArrowStyle = Infragistics.Win.UltraWinToolbars.DropDownArrowStyle.SegmentedStateButton
AddHandler contextualMenu.BeforeToolDropdown, AddressOf Me.contextualMenu_BeforeToolDropdown

Dim deleteItem As ButtonTool = New ButtonTool("delete")
deleteItem.SharedProps.AppearancesSmall.Appearance.Image = ImagesResources.Delete
deleteItem.SharedProps.Caption = Captions.Delete
AddHandler deleteItem.ToolClick, AddressOf Me.DeleteClick

Dim closeItem As ButtonTool = New ButtonTool("close")
closeItem.SharedProps.AppearancesSmall.Appearance.Image = ImagesResources.Close
closeItem.SharedProps.Caption = Captions.Close
AddHandler closeItem.ToolClick, AddressOf Me.CloseClick

Me.BaseToolbarsManager.Tools.Add(contextualMenu)
Me.BaseToolbarsManager.Tools.Add(closeItem)
Me.BaseToolbarsManager.Tools.Add(deleteItem)

contextualMenu.Tools.AddTool(deleteItem.Key)
contextualMenu.Tools.AddTool(closeItem.Key)

Me.SetcontextualMenu(Me.grid, key)
1

There are 1 answers

3
SteveFerg On BEST ANSWER

As per my comment above, give this function call a try after the visible and invisible call:

Private Sub MyDoEvents()
    Dim CurrMsg         As MSG

    'The following loop extract all messages from the queue and dispatch them
    'to the appropriate window.
    Do While PeekMessage(CurrMsg, 0, 0, 0, PM_REMOVE) <> 0
        TranslateMessage CurrMsg
        DispatchMessage CurrMsg
    Loop
End Sub

This will make sure the code gets executed within the cell click event.