请问C#里怎么把radioBox分组?

lagger 2004-05-02 08:33:50
比如我有四个radioBox,想把1,2分成一组,3,4分成一组隶属于前面的第一组,怎么分?
...全文
674 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
lagger 2004-05-02
  • 打赏
  • 举报
回复
.....
如果我有一百个就用一百个if了?
dark012002 2004-05-02
  • 打赏
  • 举报
回复
if(this.radiobutton5.checked)
{
// do something..
}

if( !this.radioButton6.checked)
{
// do anything...
}
lagger 2004-05-02
  • 打赏
  • 举报
回复
哈哈,原来可以把控件拖进去的,只是差怎么知道哪个radionbutton给选择的判断了.
lagger 2004-05-02
  • 打赏
  • 举报
回复
谢谢,不过看得很晕,只能在代码里改,不能在设计器里面改吗?还有,我在处理里,怎么知道哪个radiobutton选择了,哪个没有选择?
youngby 2004-05-02
  • 打赏
  • 举报
回复
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.panel1 = new System.Windows.Forms.Panel();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.groupBox1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(32, 32);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(240, 184);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "groupBox1";
//
// radioButton1
//
this.radioButton1.Location = new System.Drawing.Point(48, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.TabIndex = 0;
this.radioButton1.Text = "radioButton1";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(56, 144);
this.radioButton2.Name = "radioButton2";
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "radioButton2";
//
// panel1
//
this.panel1.Controls.Add(this.radioButton4);
this.panel1.Controls.Add(this.radioButton3);
this.panel1.Location = new System.Drawing.Point(48, 256);
this.panel1.Name = "panel1";
this.panel1.TabIndex = 1;
//
// radioButton3
//
this.radioButton3.Location = new System.Drawing.Point(32, 16);
this.radioButton3.Name = "radioButton3";
this.radioButton3.TabIndex = 2;
this.radioButton3.Text = "radioButton3";
//
// radioButton4
//
this.radioButton4.Location = new System.Drawing.Point(32, 64);
this.radioButton4.Name = "radioButton4";
this.radioButton4.TabIndex = 3;
this.radioButton4.Text = "radioButton4";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 373);
this.Controls.Add(this.panel1);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);

}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧