CheckBox.ThreeState : CheckBox « System.Windows.Forms « C# / C Sharp by API

Home
C# / C Sharp by API
1.Microsoft.Win32
2.System
3.System.Collections
4.System.Collections.Generic
5.System.Collections.Specialized
6.System.ComponentModel
7.System.Configuration
8.System.Data
9.System.Data.Common
10.System.Data.Linq
11.System.Data.Odbc
12.System.Data.OleDb
13.System.Data.Sql
14.System.Data.SqlClient
15.System.Diagnostics
16.System.DirectoryServices
17.System.Drawing
18.System.Drawing.Drawing2D
19.System.Drawing.Imaging
20.System.Drawing.Printing
21.System.Drawing.Text
22.System.EnterpriseServices
23.System.Globalization
24.System.IO
25.System.IO.Compression
26.System.IO.IsolatedStorage
27.System.IO.Ports
28.System.Linq
29.System.Management
30.System.Media
31.System.Messaging
32.System.Net
33.System.Net.Mail
34.System.Net.NetworkInformation
35.System.Net.Sockets
36.System.Reflection
37.System.Resources
38.System.Runtime
39.System.Runtime.CompilerServices
40.System.Runtime.InteropServices
41.System.Runtime.Remoting
42.System.Runtime.Remoting.Channels
43.System.Runtime.Remoting.Channels.Http
44.System.Runtime.Remoting.Messaging
45.System.Runtime.Serialization
46.System.Runtime.Serialization.Formatters.Binary
47.System.Runtime.Serialization.Formatters.Soap
48.System.Security
49.System.Security.AccessControl
50.System.Security.Cryptography
51.System.Security.Cryptography.X509Certificates
52.System.Security.Permissions
53.System.Security.Policy
54.System.Security.Principal
55.System.ServiceProcess
56.System.Text
57.System.Text.RegularExpressions
58.System.Threading
59.System.Timers
60.System.Web.Security
61.System.Web.Services
62.System.Windows.Controls
63.System.Windows.Forms
64.System.Xml
65.System.Xml.Linq
66.System.Xml.Schema
67.System.Xml.Serialization
68.System.Xml.XPath
69.System.Xml.Xsl
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp by API » System.Windows.Forms » CheckBox 
CheckBox.ThreeState
 
/*
Professional Windows GUI Programming Using C#
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, 
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow

Publisher: Peer Information
ISBN: 1861007663
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace CheckBox
{
  /// <summary>
  /// Summary description for CheckBoxStyle.
  /// </summary>
  public class CheckBoxStyle : System.Windows.Forms.Form
  {
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.CheckBox chk_option1;
    private System.Windows.Forms.CheckBox chk_option2;
    private System.Windows.Forms.CheckBox chk_option3;
    private System.Windows.Forms.CheckBox chk_option4;
    private System.Windows.Forms.Button button1;
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.Container components = null;

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

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
    }

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

    #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.chk_option1 = new System.Windows.Forms.CheckBox();
      this.label1 = new System.Windows.Forms.Label();
      this.chk_option2 = new System.Windows.Forms.CheckBox();
      this.chk_option3 = new System.Windows.Forms.CheckBox();
      this.chk_option4 = new System.Windows.Forms.CheckBox();
      this.groupBox1 = new System.Windows.Forms.GroupBox();
      this.button1 = new System.Windows.Forms.Button();
      this.groupBox1.SuspendLayout();
      this.SuspendLayout();
      // 
      // chk_option1
      // 
      this.chk_option1.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
      this.chk_option1.Location = new System.Drawing.Point(4024);
      this.chk_option1.Name = "chk_option1";
      this.chk_option1.Size = new System.Drawing.Size(19224);
      this.chk_option1.TabIndex = 0;
      this.chk_option1.Text = "Windows 2000 / Windows XP";
      this.chk_option1.ThreeState = true;
      // 
      // label1
      // 
      this.label1.Location = new System.Drawing.Point(1624);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(29616);
      this.label1.TabIndex = 1;
      this.label1.Text = "The following products are developed by Microsoft Corp.";
      // 
      // chk_option2
      // 
      this.chk_option2.Location = new System.Drawing.Point(4056);
      this.chk_option2.Name = "chk_option2";
      this.chk_option2.Size = new System.Drawing.Size(19224);
      this.chk_option2.TabIndex = 0;
      this.chk_option2.Text = "JAVA";
      // 
      // chk_option3
      // 
      this.chk_option3.Appearance = System.Windows.Forms.Appearance.Button;
      this.chk_option3.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
      this.chk_option3.Location = new System.Drawing.Point(4088);
      this.chk_option3.Name = "chk_option3";
      this.chk_option3.Size = new System.Drawing.Size(19224);
      this.chk_option3.TabIndex = 0;
      this.chk_option3.Text = "Visual C# and .NET";
      // 
      // chk_option4
      // 
      this.chk_option4.Appearance = System.Windows.Forms.Appearance.Button;
      this.chk_option4.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
      this.chk_option4.Location = new System.Drawing.Point(40120);
      this.chk_option4.Name = "chk_option4";
      this.chk_option4.Size = new System.Drawing.Size(19224);
      this.chk_option4.TabIndex = 0;
      this.chk_option4.Text = "Oracle Database";
      // 
      // groupBox1
      // 
      this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
                                          this.chk_option2,
                                          this.chk_option4,
                                          this.chk_option3,
                                          this.chk_option1});
      this.groupBox1.Location = new System.Drawing.Point(1656);
      this.groupBox1.Name = "groupBox1";
      this.groupBox1.Size = new System.Drawing.Size(280152);
      this.groupBox1.TabIndex = 2;
      this.groupBox1.TabStop = false;
      this.groupBox1.Text = "Select All Correct Options";
      // 
      // button1
      // 
      this.button1.Location = new System.Drawing.Point(16216);
      this.button1.Name = "button1";
      this.button1.TabIndex = 3;
      this.button1.Text = "Done ";
      this.button1.Click += new System.EventHandler(this.button1_Click);
      // 
      // CheckBoxStyle
      // 
      this.AutoScaleBaseSize = new System.Drawing.Size(513);
      this.ClientSize = new System.Drawing.Size(328253);
      this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                      this.button1,
                                      this.groupBox1,
                                      this.label1});
      this.Name = "CheckBoxStyle";
      this.Text = "Check Boxes";
      this.Load += new System.EventHandler(this.CheckBoxStyle_Load);
      this.groupBox1.ResumeLayout(false);
      this.ResumeLayout(false);

    }
    #endregion

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

    private void CheckBoxStyle_Load(object sender, System.EventArgs e)
    {
      // Load the Image that we want to display on the button
      Image imga = Image.FromFile("WRENCH.ICO");
      // Assign the Image for the checkbox
      chk_option3.Image = imga;
      // Align the image on the face of the checkbox
      chk_option3.ImageAlign = ContentAlignment.MiddleRight;
      // Select the background color for the checkbox
      chk_option3.BackColor = Color.LightBlue ;

      // Load the Image that we want to display on the button
      imga = Image.FromFile("EYE.ICO");
      // Assign the Image for the checkbox
      chk_option4.Image = imga;
      // Align the image on the face of the checkbox
      chk_option4.ImageAlign = ContentAlignment.MiddleCenter;
      // Select the background color for the checkbox
      chk_option4.BackColor = Color.LightBlue ;

    }

    private void button1_Click(object sender, System.EventArgs e)
    {
      string str_opt_selected = "Options Selected are ..\n" ;
  
      // Check which options are selected for every checkbox
      // using the Checked property

      if chk_option1.Checked 
        str_opt_selected = str_opt_selected + chk_option1.Text + "\n";
      if chk_option2.Checked 
        str_opt_selected = str_opt_selected + chk_option2.Text + "\n";
      if chk_option3.Checked 
        str_opt_selected = str_opt_selected + chk_option3.Text + "\n";
      if chk_option4.Checked 
        str_opt_selected = str_opt_selected + chk_option4.Text + "\n";

      MessageBox.Show(str_opt_selected , "Checked Options");

    }
  }
}

   
  
Related examples in the same category
1.new CheckBox()
2.extends CheckBox
3.CheckBox.CheckAlign
4.CheckBox.Checked
5.CheckBox.CheckedChanged
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.