Deselect text when right-click DGV cell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robertybob
    New Member
    • Feb 2013
    • 116

    Deselect text when right-click DGV cell

    Hi

    I have implemented a right-click event on DGV cells. However if the text in the cell is being edited (ie, has a cursor or selected text) the right-click event doesn't fire and the standard context menu appears instead.

    Is there a way to force the firing of the event rather than the context?

    I've tried everything from ClearSelections (), EndEdit(), CurrentCell = Nothing etc on noting the right-click and nothing works.

    Any ideas?

    Thanks!
  • mcupito
    Contributor
    • Aug 2013
    • 294

    #2
    Did you think of Leave? You could put an
    Code:
    If Then
    statement in your Right Click event that handles if that DGV cell has focus, and if so, then try to call your Leave or .CellLeave method. (Note: .CellLeave is for .NET 4.5 and later.)


    Comment

    Working...