Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //using System.Windows.Forms;
- DialogResult ShowMessage(string text, string caption = "")
- {
- var result = DialogResult.None;
- using (Form frm = new Form())
- {
- frm.Text = caption;
- frm.MinimumSize = new Size(350, 250);
- frm.SizeGripStyle = SizeGripStyle.Hide;
- Button btn = new Button();
- frm.Controls.Add(btn);
- btn.Left = frm.ClientSize.Width - btn.Width - btn.Margin.Right;
- btn.Top = frm.ClientSize.Height - btn.Height - btn.Margin.Bottom;
- btn.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
- btn.Text = "OK";
- btn.DialogResult = DialogResult.OK;
- btn.Click += (s, e) => { ((Control)s).FindForm().Close(); };
- TextBox tb = new TextBox();
- frm.Controls.Add(tb);
- tb.Multiline = true;
- tb.ReadOnly = true;
- tb.BackColor = SystemColors.Window;
- tb.SetBounds(0, 0, frm.ClientSize.Width, btn.Top - btn.Margin.Top);
- tb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
- tb.ScrollBars = ScrollBars.Both;
- tb.Text = text;
- result = frm.ShowDialog();
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement