本文整理匯總了C#中System.Windows.Forms.CheckBox類的典型用法代碼示例。如果您正苦於以下問題:C# CheckBox類的具體用法?C# CheckBox怎麽用?C# CheckBox使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CheckBox類屬於System.Windows.Forms命名空間,在下文中一共展示了CheckBox類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: InstantiateMyCheckBox
public void InstantiateMyCheckBox()
{
// Create and initialize a CheckBox.
CheckBox checkBox1 = new CheckBox();
// Make the check box control appear as a toggle button.
checkBox1.Appearance = Appearance.Button;
// Turn off the update of the display on the click of the control.
checkBox1.AutoCheck = false;
// Add the check box control to the form.
Controls.Add(checkBox1);
}
示例2: new CheckBox()
//引入命名空間
using System;
using System.Drawing;
using System.Windows.Forms;
class CheckBoxWithLabel: Form
{
Label label;
FontStyle fs = 0;
FontStyle[] afs = { FontStyle.Bold,FontStyle.Italic, FontStyle.Underline, FontStyle.Strikeout };
public static void Main()
{
Application.Run(new CheckBoxWithLabel());
}
public CheckBoxWithLabel()
{
int cyText = Font.Height;
int cxText = cyText / 2;
string[] astrText = {"Bold", "Italic", "Underline", "Strikeout"};
label = new Label();
label.Parent = this;
label.Text = "Sample Text";
label.AutoSize = true;
for (int i = 0; i < 4; i++)
{
CheckBox chkbox = new CheckBox();
chkbox.Parent = this;
chkbox.Text = astrText[i];
chkbox.Location = new Point(2 * cxText, (4 + 3 * i) * cyText / 2);
chkbox.Size = new Size(12 * cxText, cyText);
chkbox.CheckedChanged += new EventHandler(CheckBoxOnCheckedChanged);
}
}
void CheckBoxOnCheckedChanged(object obj, EventArgs ea)
{
for (int i = 0; i < 4; i++)
if (((CheckBox) Controls[i + 1]).Checked)
fs |= afs[i];
label.Font = new Font(label.Font, fs);
}
}