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.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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;


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.