• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 392
  • Last Modified:

Popup Form on Cursor or button location

I am starting to go in circles looking for the best way to do this, so I want to ask:

I am trying to open a small form from a button click event in a VB.Net 2008 Windows app. The form with the button is a child form within a MDIParent form. The popup form needs to open up  at the position where either my button is or where my cursor is. And lastly, the popup form needs to return a value back to the child form (should this be a dialog or a modal form?).

Please post a code sample so I can follow it. Also, let me know if the popup form should have a specific StartPosition  (like "Manual"). Thanks! I hope I explained this good enough for you to follow. Just ask if I didn't.
  • 2
1 Solution
Daniel JungesCommented:

myPopUpForm.Location = Cursor.Position;

Place a public member on myPopUpForm and store the value that is for return.

// get the value after myPopUpForm is closed
myVar = myPopUpForm.someVar;

JeepGeekinAuthor Commented:
Thanks for the post, but I tried this. For some reason the widow opens wherever it wants. It does not open at the location we specify. If you want to see my click event code, here it is:

Private Sub picCustLookup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picCustLookup.Click
      Dim frmCust As New frmCustomer
      Dim sReturn As String
      frmCust.Location = Cursor.Position
End Sub

Open in new window

JeepGeekinAuthor Commented:
Ah. I had to set the popup window's StartPosition = Manual. That works. I have been going through several combos of this setting & the different popup form types I lost track. Thanks!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now