C# formatting a MessageBox

前端 未结 5 1218
你的背包
你的背包 2020-12-19 01:32

I want to display a MessageBox alerting the user that the process is complete, and giving a breakdown on how long each stage of the process took. I\'ve got the text that I w

相关标签:
5条回答
  • 2020-12-19 02:09

    For the record, this is in fact possible, MessageBox() expands tabs. For example:

        private void button1_Click(object sender, EventArgs e) {
            MessageBox.Show(
                "hello\tworld\r\n" + 
                "second\tline");
        }
    

    It isn't very trustworthy if the word width starts to approach the tab width. You still should prefer a little helper form with a ListView.

    0 讨论(0)
  • 2020-12-19 02:11

    Sounds like you may just want to drop a new form in there and use a few labels..

    0 讨论(0)
  • 2020-12-19 02:16

    Any reason not to just create a Form with a textbox/label using a monospace font, then call Form.ShowDialog? Sounds like a separate library with that would be overkill to me.

    0 讨论(0)
  • 2020-12-19 02:23

    I use this:

    public void myMessageBox(object str)
    {
        System.Windows.Forms.MessageBox.Show( new System.Windows.Forms.Form{ TopMost = true, Width = 300}, str.ToString() );
    }
    
    0 讨论(0)
  • 2020-12-19 02:27

    I have just written a single file replacement for MessageBox with a changeable font. You can download it here and use it like a standard MessageBox:

    http://www.codeproject.com/Articles/601900/FlexibleMessageBox-A-flexible-replacement-for-the

    Regards, Jörg

    0 讨论(0)
提交回复
热议问题