Add CheckBox to a Form : CheckBox « GUI Windows Forms « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
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
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » GUI Windows Forms » CheckBox 
22. 9. 2. Add CheckBox to a Form
Add CheckBox to a Form
using System;
using System.Windows.Forms;

public class CheckBoxFormDemo{

    [STAThread]
    public static void Main(string[] args)
    {
        Application.Run(new CheckBoxForm());
    }

}

public partial class CheckBoxForm : Form
{
    public CheckBoxForm()
    {
        InitializeComponent();
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        string[] foods = {"A""B""C""D","E","F","G","H","I","J"};

        this.SuspendLayout();

        int topPosition = 10;

        foreach (string food in foods)
        {
            CheckBox checkBox = new CheckBox();

            checkBox.Top = topPosition;
            checkBox.Left = 10;
            checkBox.Text = food;

            topPosition += 30;

            panel1.Controls.Add(checkBox);
        }

        this.ResumeLayout();
    }

}
partial class CheckBoxForm
{
    private System.ComponentModel.IContainer components = null;

    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows Form Designer generated code

    private void InitializeComponent()
    {
        this.panel1 = new System.Windows.Forms.Panel();
        this.SuspendLayout();
        // 
        // panel1
        // 
        this.panel1.AutoScroll = true;
        this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
        this.panel1.Location = new System.Drawing.Point(00);
        this.panel1.Name = "panel1";
        this.panel1.Size = new System.Drawing.Size(292266);
        this.panel1.TabIndex = 0;
        // 
        // CheckBoxForm
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292266);
        this.Controls.Add(this.panel1);
        this.Name = "CheckBoxForm";
        this.Text = "CheckBoxForm";
        this.ResumeLayout(false);
    }

    #endregion

    private System.Windows.Forms.Panel panel1;
}
22. 9. CheckBox
22. 9. 1. Change Label font by CheckBoxesChange Label font by CheckBoxes
22. 9. 2. Add CheckBox to a FormAdd CheckBox to a Form
22. 9. 3. CheckedChanged event for CheckBox
w___ww.___j__ava___2_s.__c___o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.