CheckBox Image : CheckBox « GUI Windows Form « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » GUI Windows Form » CheckBoxScreenshots 
CheckBox Image
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : 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;

    public Form1() {
        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);
        // 
        // Form1
        // 
        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 = "Form1";
        this.Text = "Check Boxes";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.groupBox1.ResumeLayout(false);
        this.ResumeLayout(false);

    }


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

    private void Form1_Load(object sender, System.EventArgs e) {
        Image imga = Image.FromFile("A.ICO");
        chk_option3.Image = imga;
        chk_option3.ImageAlign = ContentAlignment.MiddleRight;
        chk_option3.BackColor = Color.LightBlue;
        imga = Image.FromFile("B.ICO");
        chk_option4.Image = imga;
        chk_option4.ImageAlign = ContentAlignment.MiddleCenter;
        chk_option4.BackColor = Color.LightBlue;
    }

    private void button1_Click(object sender, System.EventArgs e) {
        string str_opt_selected = "Options Selected are ..\n";
        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.CheckBox with Label
2.Subclass CheckBox
3.CheckedChanged Event
4.Is CheckBox checkedIs CheckBox checked
5.CheckBox click (Selected/Unselected) eventCheckBox click (Selected/Unselected) event
6.CheckButton on a FormCheckButton on a Form
7.CheckBox StyleCheckBox Style
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.