Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15189

VS 2019 ContextMenuStrip stay displayed

$
0
0
I am using a ContextMenuStrip in my program. When I click one of the menu items the text gets copied and the menu stays displayed until I click somewhere else in the form.
The problem is that when my form loses focus because I want to open a notepad to paste the text, the ContextMenuStrip is gone.

Is there a way to keep the ContextMenuStrip visible?

Code:

    Private blnClose As Boolean = True

  Private Sub ToolStripMenuItem1_Click(sender As Object, e As EventArgs) Handles ToolStripMenuItem1.Click
        'copy the coordinate
        Clipboard.SetText(ToolStripMenuItem1.Text, TextDataFormat.Text)

    End Sub
    Private Sub ToolStripMenuItem1_MouseDown(sender As Object, e As Windows.Forms.MouseEventArgs) Handles ToolStripMenuItem1.MouseDown
        blnClose = False
    End Sub

    Private Sub ContextMenuStrip1_Closing(sender As Object, e As ToolStripDropDownClosingEventArgs) Handles ContextMenuStrip1.Closing
        e.Cancel = Not blnClose
        blnClose = True
    End Sub


Viewing all articles
Browse latest Browse all 15189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>