locked
Text alignment into center in MessageBox RRS feed

  • Question

  • I have one small question, which concerns MessageBox.Show.
    Let`s say that I want to have my text in a MessegaBox and in two or more rows.
    I can do that with MessageBox.Show("My text looooooooong.\r\n my text short");  How to put the "my short text" into the center of the text box? Cause with that the text is aligned left. I would like to have all in the cneter!
    Tuesday, April 14, 2009 7:05 PM

Answers

  • Also: Environment.NewLine() is a nicer then "\r\n" ;-)
    "The improbable we do, the impossible just takes a little longer." (Steven Parker)
    • Marked as answer by Mitja Bonca Tuesday, April 14, 2009 8:48 PM
    Tuesday, April 14, 2009 7:46 PM

All replies

  • I don't htink you can do this with the standard messagbox - it's just a hook into the old WinAPI MessageBox, which doesn;t allow formatting AFAIK.

    Two options come to mind:

    Prepend your message with spaces to "center" the
    text - you may have to compute how many spaces to use for varialbe length lines.

    Create your own messagebox, with a label, icon , and buttons.  That way you could center the label (or do any other formatting you want).  If you wanted to get really fancy, you could even support all of the same parameters as MessageBox.Show(), including dynamic buttons, icons , etc.

    Here's an examplt in VB.NET:

    http://www.levelextreme.net/wconnect/wc.dll?10,7,10,9

    and Here's one that's already built:
    http://ninopriore.com/modules.php?op=modload&name=News&file=article&sid=8&mode=thread&order=0&thold=0


    Thanks, A.m.a.L | [Remember to click "mark as answered" when you get a correct reply to your question]
    Tuesday, April 14, 2009 7:13 PM
  • Also: Environment.NewLine() is a nicer then "\r\n" ;-)
    "The improbable we do, the impossible just takes a little longer." (Steven Parker)
    • Marked as answer by Mitja Bonca Tuesday, April 14, 2009 8:48 PM
    Tuesday, April 14, 2009 7:46 PM