MessageBox Position
Messages   Related Types
This message was discovered on ASPFriends.com 'winforms-cs' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

xico
Hi all,

I'm using the System.Windows.Forms.MessageBox.Show static method to show a
MessageBox, but unfortunately it's shown in the center of the screen instead
of in the center of my Form.

Is there any way to do it?

Cheers,
- xico -

Tracking #: 50E3C19E9679BD4A9948D5C8480C8979A2505589

Reply to this message...
 
    
Douglas Reilly (VIP)

This overload of Show accepts a window as a paramter, and the docs says =
it displays the dialog "in front of" the window. Not sure if it is =
centered there, and have not tested it...

Overloads Public Shared Function Show( _
ByVal owner As IWin32Window, _
ByVal text As String, _
ByVal caption As String, _
ByVal buttons As MessageBoxButtons, _
ByVal icon As MessageBoxIcon, _
ByVal defaultButton As MessageBoxDefaultButton, _
ByVal options As MessageBoxOptions _
) As DialogResult

----- Original Message -----
From: "xico" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Wed, 29 May 2002 09:57:42 -0300
Subject: MessageBox Position
[Original message clipped]

Reply to this message...
 
    
Per Erik Lorentzen
MessageBox.Show(this, "Some text);

The "this"-parameter is the owner of the MessageBox shown, here it will =
be the class where the code recides, but it could be an instance of a =
form to. Not sure if it's centered, though...

Med hilsen
Per Erik Lorentzen
SK Data as
Click here to reveal e-mail address
----- Original Message -----=20
From: "xico" <Click here to reveal e-mail address>
To: "winforms-cs" <Click here to reveal e-mail address>
Sent: Wednesday, May 29, 2002 2:57 PM
Subject: [winforms-cs] MessageBox Position

[Original message clipped]

Reply to this message...
 
    
xico
Thanks Douglas and Per but I already tried this (passing the Form as the
owner).

Passing a owner to the Show method will create a message box without a
taskbar button, but it's screen centered instead of being centered according
to it's owner...

----- Original Message -----
From: "Per Erik Lorentzen" <Click here to reveal e-mail address>
To: "winforms-cs" <Click here to reveal e-mail address>
Sent: Wednesday, May 29, 2002 10:50 AM
Subject: [winforms-cs] Re: MessageBox Position

MessageBox.Show(this, "Some text);

The "this"-parameter is the owner of the MessageBox shown, here it will be
the class where the code recides, but it could be an instance of a form to.
Not sure if it's centered, though...

Med hilsen
Per Erik Lorentzen
SK Data as
Click here to reveal e-mail address
----- Original Message -----
From: "xico" <Click here to reveal e-mail address>
To: "winforms-cs" <Click here to reveal e-mail address>
Sent: Wednesday, May 29, 2002 2:57 PM
Subject: [winforms-cs] MessageBox Position

[Original message clipped]

| [winforms-cs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT

Reply to this message...
 
 
System.Windows.Forms.DialogResult
System.Windows.Forms.IWin32Window
System.Windows.Forms.MessageBox
System.Windows.Forms.MessageBoxButtons
System.Windows.Forms.MessageBoxDefaultButton
System.Windows.Forms.MessageBoxIcon
System.Windows.Forms.MessageBoxOptions




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com