本文整理汇总了C#中System.Windows.Forms.CheckBox.CheckedChanged事件的典型用法代码示例。如果您正苦于以下问题:C# CheckBox.CheckedChanged事件的具体用法?C# CheckBox.CheckedChanged怎么用?C# CheckBox.CheckedChanged使用的例子?那么恭喜您, 这里精选的事件代码示例或许可以为您提供帮助。您也可以进一步了解该事件所在类System.Windows.Forms.CheckBox
的用法示例。
在下文中一共展示了CheckBox.CheckedChanged事件的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckBox1_CheckedChanged
private void CheckBox1_CheckedChanged(Object sender, EventArgs e) {
MessageBox.Show("You are in the CheckBox.CheckedChanged event.");
}
示例2: Main
//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
class RadioButtons: Form
{
bool bFillEllipse;
Color colorEllipse;
static void Main()
{
Application.Run(new RadioButtons());
}
RadioButtons()
{
ResizeRedraw = true;
string[] astrColor = { "Black", "Blue", "Green", "Cyan"};
GroupBox grpbox = new GroupBox();
grpbox.Parent = this;
grpbox.Text = "Color";
grpbox.Location = new Point(Font.Height / 2, Font.Height / 2);
grpbox.Size = new Size(9 * Font.Height, (3 * astrColor.Length + 4) * Font.Height / 2);
for (int i = 0; i < astrColor.Length; i++)
{
RadioButton radiobtn = new RadioButton();
radiobtn.Parent = grpbox;
radiobtn.Text = astrColor[i];
radiobtn.Location = new Point(Font.Height,3 * (i + 1) * Font.Height / 2);
radiobtn.Size = new Size(7 * Font.Height,3 * Font.Height / 2);
radiobtn.CheckedChanged += new EventHandler(RadioButtonOnCheckedChanged);
radiobtn.Checked = true;
}
CheckBox chkbox = new CheckBox();
chkbox.Parent = this;
chkbox.Text = "Fill Ellipse";
chkbox.Location = new Point(Font.Height, 3 * (astrColor.Length + 2) * Font.Height / 2);
chkbox.Size = new Size(Font.Height * 7, 3 * Font.Height / 2);
chkbox.CheckedChanged += new EventHandler(CheckBoxOnCheckedChanged);
}
void RadioButtonOnCheckedChanged(object obj, EventArgs ea)
{
RadioButton radiobtn = (RadioButton) obj;
if(radiobtn.Checked)
{
colorEllipse = Color.FromName(radiobtn.Text);
Invalidate(false);
}
}
void CheckBoxOnCheckedChanged(object obj, EventArgs ea)
{
bFillEllipse = ((CheckBox)obj).Checked;
Invalidate(false);
}
protected override void OnPaint(PaintEventArgs pea)
{
Graphics grfx = pea.Graphics;
Rectangle rect = new Rectangle(10 * Font.Height, 0,
ClientSize.Width -
10 * Font.Height - 1,
ClientSize.Height - 1);
if(bFillEllipse)
grfx.FillEllipse(new SolidBrush(colorEllipse), rect);
else
grfx.DrawEllipse(new Pen(colorEllipse), rect);
}
}