CheckButton on a Form : CheckBox « GUI Windows Form « C# / C Sharp






CheckButton on a Form

CheckButton on a Form
/*
C# Programming Tips & Techniques
by Charles Wright, Kris Jamsa

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

namespace CheckButton
{
  /// <summary>
  /// Summary description for FormCheckButton.
  /// </summary>
  public class FormCheckButton : System.Windows.Forms.Form
  {
    private System.Windows.Forms.CheckBox checkBox1;
    private System.Windows.Forms.Button button1;
    private System.ComponentModel.IContainer components;

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

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
      checkBox1.Appearance = Appearance.Button;
      checkBox1.FlatStyle = FlatStyle.System;
      checkBox1.TextAlign = ContentAlignment.MiddleCenter;
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    protected override void Dispose( bool disposing )
    {
      if( disposing )
      {
        if (components != null) 
        {
          components.Dispose();
        }
      }
      base.Dispose( disposing );
    }

    #region Windows Form Designer generated code
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
      this.button1 = new System.Windows.Forms.Button();
      this.checkBox1 = new System.Windows.Forms.CheckBox();
      this.SuspendLayout();
      // 
      // button1
      // 
      this.button1.Location = new System.Drawing.Point(72, 40);
      this.button1.Name = "button1";
      this.button1.Size = new System.Drawing.Size(104, 32);
      this.button1.TabIndex = 1;
      this.button1.Text = "button1";
      // 
      // checkBox1
      // 
      this.checkBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
      this.checkBox1.Location = new System.Drawing.Point(72, 88);
      this.checkBox1.Name = "checkBox1";
      this.checkBox1.Size = new System.Drawing.Size(104, 32);
      this.checkBox1.TabIndex = 0;
      this.checkBox1.Text = "checkBox1";
      // 
      // FormCheckButton
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 141);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.button1,
                                      this.checkBox1});
      this.Name = "FormCheckButton";
      this.Text = "FormCheckButton";
      this.ResumeLayout(false);

    }
    #endregion

    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() 
    {
      Application.Run(new FormCheckButton());
    }
  }
}



           
       








Related examples in the same category

1.CheckBox with Label
2.CheckBox Image
3.Subclass CheckBox
4.CheckedChanged Event
5.Is CheckBox checkedIs CheckBox checked
6.CheckBox click (Selected/Unselected) eventCheckBox click (Selected/Unselected) event
7.CheckBox StyleCheckBox Style