Thursday, June 11, 2015

MessageBox using Winform and richtextbox

private void ShowRichMessageBox(string title, string message)
        {
            RichTextBox rtbMessage = new RichTextBox();
            rtbMessage.Text = message;
            rtbMessage.Dock = DockStyle.Fill;
            rtbMessage.ReadOnly = true;
            rtbMessage.BorderStyle = BorderStyle.FixedSingle;

            Form RichMessageBox = new Form();
            RichMessageBox.Text = title;
            RichMessageBox.StartPosition = FormStartPosition.CenterScreen;
            RichMessageBox.MaximizeBox = false;
            RichMessageBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            RichMessageBox.Size = new Size(300, 250);

            RichMessageBox.Controls.Add(rtbMessage);
            RichMessageBox.ShowDialog();
        }