当前位置: 首页>>代码示例>>C#>>正文


C# CheckBox.CheckAlign属性代码示例

本文整理汇总了C#中System.Windows.Forms.CheckBox.CheckAlign属性的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.CheckAlign属性的具体用法?C# CheckBox.CheckAlign怎么用?C# CheckBox.CheckAlign使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.CheckBox的用法示例。


在下文中一共展示了CheckBox.CheckAlign属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AdjustMyCheckBoxProperties

private void AdjustMyCheckBoxProperties()
 {
    // Change the ThreeState and CheckAlign properties on every other click.
    if (!checkBox1.ThreeState)
    {
       checkBox1.ThreeState = true;
       checkBox1.CheckAlign = ContentAlignment.MiddleRight;
    }
    else
    {
       checkBox1.ThreeState = false;
       checkBox1.CheckAlign = ContentAlignment.MiddleLeft;
    }

    // Concatenate the property values together on three lines.
    label1.Text = "ThreeState: " + checkBox1.ThreeState.ToString() + "\n" +
                  "Checked: " + checkBox1.Checked.ToString() + "\n" +
                  "CheckState: " + checkBox1.CheckState.ToString(); 
 }
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:19,代码来源:CheckBox.CheckAlign

示例2: Form1

//引入命名空间
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(40, 24);
        this.chk_option1.Name = "chk_option1";
        this.chk_option1.Size = new System.Drawing.Size(192, 24);
        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(16, 24);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(296, 16);
        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(40, 56);
        this.chk_option2.Name = "chk_option2";
        this.chk_option2.Size = new System.Drawing.Size(192, 24);
        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(40, 88);
        this.chk_option3.Name = "chk_option3";
        this.chk_option3.Size = new System.Drawing.Size(192, 24);
        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(40, 120);
        this.chk_option4.Name = "chk_option4";
        this.chk_option4.Size = new System.Drawing.Size(192, 24);
        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(16, 56);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(280, 152);
        this.groupBox1.TabIndex = 2;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "Select All Correct Options";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(16, 216);
        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(5, 13);
        this.ClientSize = new System.Drawing.Size(328, 253);
        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");

    }
}
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:147,代码来源:CheckBox.CheckAlign


注:本文中的System.Windows.Forms.CheckBox.CheckAlign属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。