以编程方式添加标签和单选按钮。在小组中 [英] Add label and radiobuttons programatically. In a Panel

查看:67
本文介绍了以编程方式添加标签和单选按钮。在小组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我必须在表格上添加大约9个面板,每个面板包含:1个标签,3个radiobuttons。

它类似于测试表格。

我必须使用Panels,因为它会帮助我查看答案

我试过这个,但是radiobuttons没有显示在表格上:



I have and application in which I have to add, on a form , about 9 Panels, each panel containing: 1 label, 3 radiobuttons.
It''s something like a test form.
I must use Panels, because it will help me on checking the answers
I tried this, but the radiobuttons don''t show up on the form:

for (int i = 0; i < 9; i++)
           {
               Panel pan = new Panel();
               pan.Name = "panel" + i;
               pan.Location = new Point(46, 76 + i * 105);
              // pan.Size = new Size(340, 100);
               Label l = new Label();
               l.Text = "something";
               l.Font = new Font("Segoe UI", 12);
               l.AutoSize = true;

               RadioButton mr =new RadioButton();
               mr.Name = "mrb" + i;
               //mr.Location = new Point(46,90+i*105);
               mr.Font = new Font("Segoe UI", 12);
               mr.Show();
               RadioButton mr1 =new RadioButton();
               mr1.Name = "mrb" + i;
              // mr1.Location = new Point(46+mr.Size.Width+5, 90 + i * 105);
               mr1.Font = new Font("Segoe UI", 12);
              RadioButton mr2 =new RadioButton();
               mr2.Name = "mrb" + i;
              // mr2.Location = new Point(46+mr1.Size.Width+5, 90 + i * 105);
               mr2.Font = new Font("Segoe UI", 12);
               pan.Controls.Add(l);
               pan.Controls.Add(mr);
               pan.Controls.Add(mr1);
               pan.Controls.Add(mr2);
               ls.Add(pan);
               this.Controls.Add(pan);
               pan.Show();
           }
           }





请稍微帮助一下......

谢谢你



A little help, please...
Thank you

推荐答案

你应该取消注释location-statements并尝试将它们放在正确的位置:)
You should uncomment the location-statements and try to position them on the right location :)


这篇关于以编程方式添加标签和单选按钮。在小组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆