When my program calls MsgBox it appears in the middle of the monitor. Anyone know how to move it somewhere within the boundries of my program's window?

I figured it out. I had to create another Form then call it's ShowDialog() method. I renamed class Form2 to MyMsgBox, and run the code below

                    Dim box As New MyMsgBox()
                    box.lblText.Text = "Division by 0 error"

I am not aware of a way to set the location of a message box, but you can create a custom dialog box to fit your needs.

I have a custom dialog written in WinForms that has a multiline textbox for the data. (Acts just like a JIT messagebox)

Would you like me to post it?


Took a while for the site to refresh for me, didn't know it was answered. I'm sorry for the thread revive.

I found the solution by googling a bit more than I had before posting the question. I'm just learning vb.net too.


The .Net MessageBox is just a wrapper for the Win API MessageBox. You could move it using the API SetWindowPosition function, but retrieving its handle gets a bit messy with enumerating the threadwindows and seeking the dialog class name "#32770".

That said, you went the correct route.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.