日期:2014-05-18 浏览次数:20990 次
private void checkBox_CheckedChanged(object sender, EventArgs e)
{
    if ((sender as CheckBox).Checked==true)
    {
        foreach (CheckBox chk in (sender as CheckBox).Parent.Controls)
        {
            if (chk != sender) chk.Checked = false;
        }
    }
}
------解决方案--------------------
楼主不喜欢radiobutton的形状吧
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace WindowsFormsApplication70
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            RadioButtonEx RB1 = new RadioButtonEx();
            RB1.Parent = this;
            RB1.Text = "1111111";
            RadioButtonEx RB2 = new RadioButtonEx();
            RB2.Parent = this;
            RB2.Location = new Point(0, 50);
            RB2.Text = "2222222";
        }
        class RadioButtonEx : RadioButton
        {
            protected override void OnPaint(PaintEventArgs pevent)
            {
                pevent.Graphics.FillRectangle(new SolidBrush(this.BackColor), pevent.ClipRectangle);
                CheckBoxRenderer.DrawCheckBox(pevent.Graphics, new Point(0, 0), this.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal);
                pevent.Graphics.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), new PointF(20, 0));