Message box builder : MessageBox « GUI Windows Form « C# / C Sharp

C# / C Sharp
1. 2D Graphics
2. Collections Data Structure
3. Components
4. Database ADO.net
5. Development Class
6. Event
7. File Stream
8. GUI Windows Form
9. Language Basics
10. Network
11. Office
12. Regular Expressions
13. Services Event
14. Thread
15. Web Services
16. Windows
17. XML
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
C# / C Sharp » GUI Windows Form » MessageBoxScreenshots 
Message box builder
Message box builder

/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

Publisher: Osborne/McGraw-Hill (December 28, 2001)
ISBN: 0072193794
*/
namespace MessageBoxBuilder
{
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
  using System.IO;
  using System.Threading;

    /// <summary>
    ///    Summary description for Form1.
    /// </summary>
    public class MainForm : System.Windows.Forms.Form
    {
    private System.ComponentModel.IContainer components;
    private System.Windows.Forms.Button btnPreview;
    private System.Windows.Forms.Button btnCancel;
    private System.Windows.Forms.Button btnOK;
    private System.Windows.Forms.TextBox txtCaption;
    private System.Windows.Forms.GroupBox grpCaption;
    private System.Windows.Forms.TextBox txtMessage;
    private System.Windows.Forms.GroupBox grpMessage;

    private MessageBoxButtons btnStyle;
    private MessageBoxIcon iconStyle;
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.ImageList imageList1;
    private System.Windows.Forms.CheckBox cbnVisualCSharp;
    private System.Windows.Forms.CheckBox cbnVisualCPP;
    private System.Windows.Forms.CheckBox cbnVisualBasic;
    private System.Windows.Forms.CheckBox cbnUseMFC;
    private System.Windows.Forms.GroupBox grpButtons;
    private System.Windows.Forms.GroupBox grpDefault;
    private System.Windows.Forms.Button btnDefault3;
    private System.Windows.Forms.Button btnDefault2;
    private System.Windows.Forms.Button btnDefault1;
    private System.Windows.Forms.ComboBox cboButtons;
    private System.Windows.Forms.GroupBox grpSend;
    private System.Windows.Forms.RadioButton rdoFile;
    private System.Windows.Forms.RadioButton rdoClipboard;
    private System.Windows.Forms.GroupBox grpOptions;
    private System.Windows.Forms.CheckBox cbnDeclareIt;
    private System.Windows.Forms.CheckBox cbnBuildSwitch;
    private System.Windows.Forms.Label lblVariable;
    private System.Windows.Forms.CheckBox cbnUseReturnVar;
    private System.Windows.Forms.TextBox txtVariable;
    private System.Windows.Forms.GroupBox grpCode;
    private System.Windows.Forms.TextBox txtCode;
    private System.Windows.Forms.GroupBox grpSample;
    private System.Windows.Forms.Button btnSample4;
    private System.Windows.Forms.Button btnSample2;
    private System.Windows.Forms.Button btnSample5;
    private System.Windows.Forms.Button btnSample3;
    private System.Windows.Forms.Button btnSample1;
    private System.Windows.Forms.Label lblSampleText;
    private System.Windows.Forms.PictureBox pbIcon;
    private System.Windows.Forms.Label lblCaption;
    private System.Windows.Forms.PictureBox pictureBox1;
    private System.Windows.Forms.CheckBox cbnDefault3;
    private System.Windows.Forms.CheckBox cbnDefault2;
    private System.Windows.Forms.CheckBox cbnDefault1;
    private MessageBoxDefaultButton btnDefault;

        public MainForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();      

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
      InitForm ();
        }


        /// <summary>
        ///    Required method for Designer support - do not modify
        ///    the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
    {
      this.components = new System.ComponentModel.Container();
      //resources = new System.Resources.ResourceManager(typeof(MainForm));
      this.btnSample4 = new System.Windows.Forms.Button();
      this.btnSample5 = new System.Windows.Forms.Button();
      this.txtCaption = new System.Windows.Forms.TextBox();
      this.btnSample1 = new System.Windows.Forms.Button();
      this.btnSample2 = new System.Windows.Forms.Button();
      this.btnSample3 = new System.Windows.Forms.Button();
      this.cbnBuildSwitch = new System.Windows.Forms.CheckBox();
      this.pbIcon = new System.Windows.Forms.PictureBox();
      this.grpSend = new System.Windows.Forms.GroupBox();
      this.rdoFile = new System.Windows.Forms.RadioButton();
      this.rdoClipboard = new System.Windows.Forms.RadioButton();
      this.cbnVisualCSharp = new System.Windows.Forms.CheckBox();
      this.cbnDefault2 = new System.Windows.Forms.CheckBox();
      this.cbnDefault3 = new System.Windows.Forms.CheckBox();
      this.lblSampleText = new System.Windows.Forms.Label();
      this.grpCaption = new System.Windows.Forms.GroupBox();
      this.btnCancel = new System.Windows.Forms.Button();
      this.grpCode = new System.Windows.Forms.GroupBox();
      this.txtCode = new System.Windows.Forms.TextBox();
      this.pictureBox1 = new System.Windows.Forms.PictureBox();
      this.btnOK = new System.Windows.Forms.Button();
      this.listBox1 = new System.Windows.Forms.ListBox();
      this.grpMessage = new System.Windows.Forms.GroupBox();
      this.txtMessage = new System.Windows.Forms.TextBox();
      this.cbnUseMFC = new System.Windows.Forms.CheckBox();
      this.cbnDeclareIt = new System.Windows.Forms.CheckBox();
      this.btnDefault3 = new System.Windows.Forms.Button();
      this.lblCaption = new System.Windows.Forms.Label();
      this.lblVariable = new System.Windows.Forms.Label();
      this.btnPreview = new System.Windows.Forms.Button();
      this.cbnVisualCPP = new System.Windows.Forms.CheckBox();
      this.cbnDefault1 = new System.Windows.Forms.CheckBox();
      this.btnDefault1 = new System.Windows.Forms.Button();
      this.groupBox1 = new System.Windows.Forms.GroupBox();
      this.btnDefault2 = new System.Windows.Forms.Button();
      this.cbnUseReturnVar = new System.Windows.Forms.CheckBox();
      this.txtVariable = new System.Windows.Forms.TextBox();
      this.grpDefault = new System.Windows.Forms.GroupBox();
      this.grpButtons = new System.Windows.Forms.GroupBox();
      this.cboButtons = new System.Windows.Forms.ComboBox();
      this.grpOptions = new System.Windows.Forms.GroupBox();
      this.cbnVisualBasic = new System.Windows.Forms.CheckBox();
      this.grpSample = new System.Windows.Forms.GroupBox();
      this.imageList1 = new System.Windows.Forms.ImageList(this.components);
      this.grpSend.SuspendLayout();
      this.grpCaption.SuspendLayout();
      this.grpCode.SuspendLayout();
      this.grpMessage.SuspendLayout();
      this.groupBox1.SuspendLayout();
      this.grpDefault.SuspendLayout();
      this.grpButtons.SuspendLayout();
      this.grpOptions.SuspendLayout();
      this.grpSample.SuspendLayout();
      this.SuspendLayout();
      // 
      // btnSample4
      // 
      this.btnSample4.Font = new System.Drawing.Font("Arial"6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.btnSample4.Location = new System.Drawing.Point(168154);
      this.btnSample4.Name = "btnSample4";
      this.btnSample4.Size = new System.Drawing.Size(5718);
      this.btnSample4.TabIndex = 4;
      this.btnSample4.Text = "button5";
      this.btnSample4.Visible = false;
      // 
      // btnSample5
      // 
      this.btnSample5.Font = new System.Drawing.Font("Arial"6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.btnSample5.Location = new System.Drawing.Point(205154);
      this.btnSample5.Name = "btnSample5";
      this.btnSample5.Size = new System.Drawing.Size(5718);
      this.btnSample5.TabIndex = 4;
      this.btnSample5.Text = "button3";
      this.btnSample5.Visible = false;
      // 
      // txtCaption
      // 
      this.txtCaption.Location = new System.Drawing.Point(924);
      this.txtCaption.Name = "txtCaption";
      this.txtCaption.Size = new System.Drawing.Size(31720);
      this.txtCaption.TabIndex = 0;
      this.txtCaption.Text = "";
      this.txtCaption.TextChanged += new System.EventHandler(this.txtCaption_TextChanged);
      // 
      // btnSample1
      // 
      this.btnSample1.Font = new System.Drawing.Font("Arial"6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.btnSample1.Location = new System.Drawing.Point(56154);
      this.btnSample1.Name = "btnSample1";
      this.btnSample1.Size = new System.Drawing.Size(5618);
      this.btnSample1.TabIndex = 4;
      this.btnSample1.Text = "button1";
      this.btnSample1.Visible = false;
      // 
      // btnSample2
      // 
      this.btnSample2.Font = new System.Drawing.Font("Arial"6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.btnSample2.Location = new System.Drawing.Point(93154);
      this.btnSample2.Name = "btnSample2";
      this.btnSample2.Size = new System.Drawing.Size(5718);
      this.btnSample2.TabIndex = 4;
      this.btnSample2.Text = "button4";
      this.btnSample2.Visible = false;
      // 
      // btnSample3
      // 
      this.btnSample3.Font = new System.Drawing.Font("Arial"6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.btnSample3.Location = new System.Drawing.Point(131154);
      this.btnSample3.Name = "btnSample3";
      this.btnSample3.Size = new System.Drawing.Size(5618);
      this.btnSample3.TabIndex = 4;
      this.btnSample3.Text = "OK";
      // 
      // cbnBuildSwitch
      // 
      this.cbnBuildSwitch.Enabled = false;
      this.cbnBuildSwitch.Location = new System.Drawing.Point(22104);
      this.cbnBuildSwitch.Name = "cbnBuildSwitch";
      this.cbnBuildSwitch.Size = new System.Drawing.Size(17516);
      this.cbnBuildSwitch.TabIndex = 4;
      this.cbnBuildSwitch.Text = "Build Switch/Conditional";
      this.cbnBuildSwitch.CheckedChanged += new System.EventHandler(this.OnMessageBoxChanged);
      // 
      // pbIcon
      // 
      //his.pbIcon.Image = ((System.Drawing.Bitmap)(resources.GetObject("pbIcon.Image")));
      this.pbIcon.Location = new System.Drawing.Point(1875);
      this.pbIcon.Name = "pbIcon";
      this.pbIcon.Size = new System.Drawing.Size(3837);
      this.pbIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
      this.pbIcon.TabIndex = 2;
      this.pbIcon.TabStop = false;
      this.pbIcon.Visible = false;
      // 
      // grpSend
      // 
      this.grpSend.Controls.AddRange(new System.Windows.Forms.Control[] {
                                          this.rdoFile,
                                          this.rdoClipboard});
      this.grpSend.Location = new System.Drawing.Point(544264);
      this.grpSend.Name = "grpSend";
      this.grpSend.Size = new System.Drawing.Size(20856);
      this.grpSend.TabIndex = 9;
      this.grpSend.TabStop = false;
      this.grpSend.Text = "Send To";
      // 
      // rdoFile
      // 
      this.rdoFile.Location = new System.Drawing.Point(14119);
      this.rdoFile.Name = "rdoFile";
      this.rdoFile.Size = new System.Drawing.Size(5924);
      this.rdoFile.TabIndex = 1;
      this.rdoFile.Text = "File";
      // 
      // rdoClipboard
      // 
      this.rdoClipboard.Checked = true;
      this.rdoClipboard.Location = new System.Drawing.Point(1719);
      this.rdoClipboard.Name = "rdoClipboard";
      this.rdoClipboard.Size = new System.Drawing.Size(9424);
      this.rdoClipboard.TabIndex = 0;
      this.rdoClipboard.TabStop = true;
      this.rdoClipboard.Text = "Clipboard";
      // 
      // cbnVisualCSharp
      // 
      this.cbnVisualCSharp.AutoCheck = false;
      this.cbnVisualCSharp.Checked = true;
      this.cbnVisualCSharp.CheckState = System.Windows.Forms.CheckState.Checked;
      this.cbnVisualCSharp.Location = new System.Drawing.Point(2216);
      this.cbnVisualCSharp.Name = "cbnVisualCSharp";
      this.cbnVisualCSharp.Size = new System.Drawing.Size(10215);
      this.cbnVisualCSharp.TabIndex = 14;
      this.cbnVisualCSharp.Text = "Visual C#";
      this.cbnVisualCSharp.Click += new System.EventHandler(this.OnLanguageChanged);
      // 
      // cbnDefault2
      // 
      this.cbnDefault2.AutoCheck = false;
      this.cbnDefault2.Location = new System.Drawing.Point(3475);
      this.cbnDefault2.Name = "cbnDefault2";
      this.cbnDefault2.Size = new System.Drawing.Size(1718);
      this.cbnDefault2.TabIndex = 1;
      this.cbnDefault2.Visible = false;
      this.cbnDefault2.Click += new System.EventHandler(this.btnDefault2_Clicked);
      // 
      // cbnDefault3
      // 
      this.cbnDefault3.AutoCheck = false;
      this.cbnDefault3.Location = new System.Drawing.Point(34112);
      this.cbnDefault3.Name = "cbnDefault3";
      this.cbnDefault3.Size = new System.Drawing.Size(1717);
      this.cbnDefault3.TabIndex = 2;
      this.cbnDefault3.Visible = false;
      this.cbnDefault3.Click += new System.EventHandler(this.btnDefault3_Clicked);
      // 
      // lblSampleText
      // 
      this.lblSampleText.Location = new System.Drawing.Point(7556);
      this.lblSampleText.Name = "lblSampleText";
      this.lblSampleText.Size = new System.Drawing.Size(19794);
      this.lblSampleText.TabIndex = 3;
      this.lblSampleText.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
      // 
      // grpCaption
      // 
      this.grpCaption.Controls.AddRange(new System.Windows.Forms.Control[] {
                                           this.txtCaption});
      this.grpCaption.Location = new System.Drawing.Point(1856);
      this.grpCaption.Name = "grpCaption";
      this.grpCaption.Size = new System.Drawing.Size(34065);
      this.grpCaption.TabIndex = 6;
      this.grpCaption.TabStop = false;
      this.grpCaption.Text = "Caption";
      // 
      // btnCancel
      // 
      this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
      this.btnCancel.Location = new System.Drawing.Point(592504);
      this.btnCancel.Name = "btnCancel";
      this.btnCancel.Size = new System.Drawing.Size(10328);
      this.btnCancel.TabIndex = 8;
      this.btnCancel.Text = "Cancel";
      this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
      // 
      // grpCode
      // 
      this.grpCode.Controls.AddRange(new System.Windows.Forms.Control[] {
                                          this.txtCode});
      this.grpCode.Location = new System.Drawing.Point(232328);
      this.grpCode.Name = "grpCode";
      this.grpCode.Size = new System.Drawing.Size(520169);
      this.grpCode.TabIndex = 4;
      this.grpCode.TabStop = false;
      this.grpCode.Text = "Generated Code";
      // 
      // txtCode
      // 
      this.txtCode.Font = new System.Drawing.Font("Arial"9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
      this.txtCode.Location = new System.Drawing.Point(522);
      this.txtCode.Multiline = true;
      this.txtCode.Name = "txtCode";
      this.txtCode.ReadOnly = true;
      this.txtCode.ScrollBars = System.Windows.Forms.ScrollBars.Both;
      this.txtCode.Size = new System.Drawing.Size(491137);
      this.txtCode.TabIndex = 0;
      this.txtCode.Text = "MessageBox.Show();";
      // 
      // pictureBox1
      // 
      this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
      this.pictureBox1.Location = new System.Drawing.Point(922);
      this.pictureBox1.Name = "pictureBox1";
      this.pictureBox1.Size = new System.Drawing.Size(281159);
      this.pictureBox1.TabIndex = 0;
      this.pictureBox1.TabStop = false;
      // 
      // btnOK
      // 
      this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
      this.btnOK.Location = new System.Drawing.Point(456504);
      this.btnOK.Name = "btnOK";
      this.btnOK.Size = new System.Drawing.Size(10328);
      this.btnOK.TabIndex = 7;
      this.btnOK.Text = "OK";
      this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
      // 
      // listBox1
      // 
      this.listBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
      this.listBox1.Items.AddRange(new object[] {
                              "None",
                              "Information",
                              "Question",
                              "Exclamation",
                              "Error"});
      this.listBox1.Location = new System.Drawing.Point(1225);
      this.listBox1.Name = "listBox1";
      this.listBox1.Size = new System.Drawing.Size(188154);
      this.listBox1.TabIndex = 0;
      this.listBox1.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.listBox1_MeasureItem);
      this.listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.OnListBox1DrawItem);
      // 
      // grpMessage
      // 
      this.grpMessage.Controls.AddRange(new System.Windows.Forms.Control[] {
                                           this.txtMessage});
      this.grpMessage.Location = new System.Drawing.Point(3600);
      this.grpMessage.Name = "grpMessage";
      this.grpMessage.Size = new System.Drawing.Size(392119);
      this.grpMessage.TabIndex = 5;
      this.grpMessage.TabStop = false;
      this.grpMessage.Text = "Message";
      // 
      // txtMessage
      // 
      this.txtMessage.Location = new System.Drawing.Point(1220);
      this.txtMessage.Multiline = true;
      this.txtMessage.Name = "txtMessage";
      this.txtMessage.Size = new System.Drawing.Size(37289);
      this.txtMessage.TabIndex = 0;
      this.txtMessage.Text = "";
      this.txtMessage.TextChanged += new System.EventHandler(this.OnMessageBoxChanged);
      // 
      // cbnUseMFC
      // 
      this.cbnUseMFC.Enabled = false;
      this.cbnUseMFC.Location = new System.Drawing.Point(12836);
      this.cbnUseMFC.Name = "cbnUseMFC";
      this.cbnUseMFC.Size = new System.Drawing.Size(9514);
      this.cbnUseMFC.TabIndex = 17;
      this.cbnUseMFC.Text = "Use MFC";
      this.cbnUseMFC.CheckedChanged += new System.EventHandler(this.OnMessageBoxChanged);
      // 
      // cbnDeclareIt
      // 
      this.cbnDeclareIt.Enabled = false;
      this.cbnDeclareIt.Location = new System.Drawing.Point(2277);
      this.cbnDeclareIt.Name = "cbnDeclareIt";
      this.cbnDeclareIt.Size = new System.Drawing.Size(9517);
      this.cbnDeclareIt.TabIndex = 5;
      this.cbnDeclareIt.Text = "Declare It?";
      this.cbnDeclareIt.CheckedChanged += new System.EventHandler(this.OnMessageBoxChanged);
      // 
      // btnDefault3
      // 
      this.btnDefault3.Location = new System.Drawing.Point(77109);
      this.btnDefault3.Name = "btnDefault3";
      this.btnDefault3.Size = new System.Drawing.Size(6824);
      this.btnDefault3.TabIndex = 5;
      this.btnDefault3.Text = "button3";
      this.btnDefault3.Visible = false;
      this.btnDefault3.Click += new System.EventHandler(this.btnDefault3_OnClick);
      // 
      // lblCaption
      // 
      this.lblCaption.BackColor = System.Drawing.SystemColors.ActiveCaption;
      this.lblCaption.ForeColor = System.Drawing.SystemColors.HighlightText;
      this.lblCaption.Location = new System.Drawing.Point(922);
      this.lblCaption.Name = "lblCaption";
      this.lblCaption.Size = new System.Drawing.Size(27919);
      this.lblCaption.TabIndex = 1;
      this.lblCaption.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
      // 
      // lblVariable
      // 
      this.lblVariable.Enabled = false;
      this.lblVariable.Location = new System.Drawing.Point(750);
      this.lblVariable.Name = "lblVariable";
      this.lblVariable.Size = new System.Drawing.Size(8921);
      this.lblVariable.TabIndex = 3;
      this.lblVariable.Text = "Variable Name";
      this.lblVariable.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      // 
      // btnPreview
      // 
      this.btnPreview.Location = new System.Drawing.Point(328504);
      this.btnPreview.Name = "btnPreview";
      this.btnPreview.Size = new System.Drawing.Size(10328);
      this.btnPreview.TabIndex = 10;
      this.btnPreview.Text = "Test";
      this.btnPreview.Click += new System.EventHandler(this.btnPreview_Click);
      // 
      // cbnVisualCPP
      // 
      this.cbnVisualCPP.AutoCheck = false;
      this.cbnVisualCPP.Location = new System.Drawing.Point(12816);
      this.cbnVisualCPP.Name = "cbnVisualCPP";
      this.cbnVisualCPP.Size = new System.Drawing.Size(10215);
      this.cbnVisualCPP.TabIndex = 15;
      this.cbnVisualCPP.Text = "Visual C++";
      this.cbnVisualCPP.Click += new System.EventHandler(this.OnLanguageChanged);
      // 
      // cbnDefault1
      // 
      this.cbnDefault1.AutoCheck = false;
      this.cbnDefault1.Location = new System.Drawing.Point(3437);
      this.cbnDefault1.Name = "cbnDefault1";
      this.cbnDefault1.Size = new System.Drawing.Size(1717);
      this.cbnDefault1.TabIndex = 0;
      this