Results 1 to 3 of 3

Thread: ContextMenuStrip stay displayed

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2021
    Posts
    69

    ContextMenuStrip stay displayed

    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

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    24,069

    Re: ContextMenuStrip stay displayed

    Are you opening a new or existing text file? You can create or edit text files in code without opening a notepad window and pasting...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2021
    Posts
    69

    Re: ContextMenuStrip stay displayed

    Yes I am opening a new textfile but the textfile is just an example. I want to be able to copy it to any kind of file .doc, ppt, .txt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width