关于C#中的控件的问题

是否有可能实现控件的自动添加问题(radiobutton控件,radiobutton控件属于panel控件),可以的话,请给我具体说说,最好是能写个例子出来。我的意思是像... 是否有可能实现控件的自动添加问题(radiobutton控件,radiobutton控件属于panel控件),可以的话,请给我具体说说,最好是能写个例子出来。
我的意思是像循环样的。加个条件,就可以在满足条件的情况下就会自动添加该控件
展开
 我来答
百度网友805279e
2008-10-22 · 超过21用户采纳过TA的回答
知道答主
回答量:90
采纳率:0%
帮助的人:66.1万
展开全部
当然可以啊,控件的拖动也是由代码实现的,你也用代码生成控件就行。
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.SuspendLayout();
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(45, 71);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(95, 16);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "radioButton1";
this.radioButton1.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.radioButton1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
让他生成上面类似的代码就行。
lljdbd
2008-10-22 · 超过24用户采纳过TA的回答
知道答主
回答量:127
采纳率:0%
帮助的人:64.7万
展开全部
下面是用代码添加的过程,想在什么时候添加,就在相应事件下写上就可以了
RadioButton r1 = new RadioButton();
r1.Name = "R1";
r1.Text = "radiobutton1";
r1.Location = new Point(0, 0);
this.Controls.Add(r1);
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
149032105
2008-10-23 · TA获得超过756个赞
知道小有建树答主
回答量:1029
采纳率:0%
帮助的人:658万
展开全部
for(int i =1;i<10,i++)
{
radiobutton rob = new radiobutton();
rob.Location = new Point(0, i*10);//位置随你设
panel.Controls.Add(rob);
}

MD~

就这样就行了
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
网络剑客Eks
2008-10-22 · TA获得超过425个赞
知道小有建树答主
回答量:224
采纳率:0%
帮助的人:242万
展开全部
楼主指的是代码添加控件?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式