`MessageBox.Show` overload with `StartPosition` parameter
See original GitHub issueBackground and motivation
When Messagebox.Show is called, often it will be associated to an open window. The messagebox will show in the middle of the monitor. This is not really user friendly when the user has a large monitor or when using non-maximized forms.
Example of users working around the problem: https://stackoverflow.com/questions/1732443/center-messagebox-in-parent-form
API Proposal
namespace System.Windows.Forms;
public enum MessageBoxStartPosition
{
Default = 0,
CenterScreen = 1,
CenterParent = 2
}
public static DialogResult Show(
string? text,
string? caption,
MessageBoxButtons buttons,
MessageBoxIcon icon,
MessageBoxDefaultButton defaultButton,
MessageBoxOptions options,
MessageBoxStartPosition startPosition)
API Usage
MessageBox.Show("Test Message box text","Test Caption",
MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxStartPosition.CenterParent)
Alternative Designs
No response
Risks
No response
Will this feature affect UI controls?
No.
Issue Analytics
- State:
- Created 5 months ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
MessageBox.Show Method (System.Windows.Forms)
Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, default button, and options. Show(String,...
Read more >Why does my MessageBox.Show generate an error about ...
1 and 2) MessageBox doesn't have an overload for (string, MessageBoxButtons). ... Show(string, string)' has some invalid arguments.
Read more >Position a Windows Forms MessageBox in C# - CodeProject
There's no method in C# to position a MessageBox . But in C++, you can position a message box by finding the message...
Read more >WinForms MessageBox.Show Examples
Show method calls is important. The compiler applies overload resolution to call the best method in the method group.
Read more >Messagebox Location C
How to display Message Box in Android Using Xamarin C#. Pfad und Name der Hilfedatei, ... How to set a custom position for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Something like this should work:
I agree that TD is a bit more verbose, but it’s also feature-ruch and (which is important) it is test-friendly. Migrating from MB to TD isn’t that difficult, one can add a quick helper method that would translate MB calls to comparable TD calls.