Font font1 = new Font("宋体", 9, FontStyle.Regular);
Font font2 = new Font("宋体", 9, FontStyle.Bold);
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Font == font1)
{
radioButton1.Font = font2;
radioButton1.BackColor = Color.SkyBlue;
radioButton1.ForeColor = Color.Red;
}
else
{
radioButton1.Font = font1;
radioButton1.BackColor = Color.Transparent;
radioButton1.ForeColor = Color.Black;
}
}
分别改了字体,背景颜色和前景色。
Font font2 = new Font("宋体", 9, FontStyle.Bold);
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Font == font1)
{
radioButton1.Font = font2;
radioButton1.BackColor = Color.SkyBlue;
radioButton1.ForeColor = Color.Red;
}
else
{
radioButton1.Font = font1;
radioButton1.BackColor = Color.Transparent;
radioButton1.ForeColor = Color.Black;
}
}
分别改了字体,背景颜色和前景色。
radioButton1.Font = font1;
1、for循环得到选中项的索引
2、设置该索引位置项的font属性建议:
这种集合形式跟单个的radioButton一样,先通过属性设置好了以后达到预期的效果 然后看Designer文件
里面有相应的代码