Windows Develop Bookmark and Share   
 index > Windows Forms Designer > How do I pop up/show a form at the mouse coordinates - like a context menu?
 

How do I pop up/show a form at the mouse coordinates - like a context menu?

Hi all,

     I'm trying to open a form at the location of the mouse. It resembles the way the context menu location works. My code doesn't seem to be working - it's just opening, but not at the correct location. I'm hoping someone can tell me what I'm doing wrong.

Thanks ahead of time,
Denvas

CODE: 

    Private Sub ctxHist_Show_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctxHist_Show.Click
        Dim fm As New frmEdit

        With fm
            .Location = Control.MousePosition
            .ShowDialog()
        End With
    End Sub
MigrationUser 1  Friday, June 25, 2004 12:18 PM
Check out the Form.StartPosition property.

Tony
MigrationUser 1  Friday, June 25, 2004 1:42 PM
Ahh. Thanks Tony, that did it. I was confused at first until I realized it has to be set to manual first:
.StartPosition = FormStartPosition.Manual
.Location = Control.MousePosition


Cool.

- Denvas
MigrationUser 1  Friday, June 25, 2004 3:18 PM

You can use google to search for other answers

Custom Search

More Threads

• Class not registered
• problem with the collection control
• Validation With Tab Pages
• IPersistComponentSettings
• Visual Studio 2005 Forms Designer Bugs
• BUG: Inheritance using custom controls
• how to validate masktextbox
• designer on root component
• Controls emulating Mac interface
• TabControl behaving strangly