C# 表单上的单选按钮定位
我试图动态地将单选按钮添加到表单中(这样,当用户单击按钮时,我可以更改它们的值),但随后我添加了单个按钮的位置信息,这些按钮不再显示。我可以在表单上看到GroupBox的轮廓,以及每侧几百个像素C# 表单上的单选按钮定位,c#,C#,我试图动态地将单选按钮添加到表单中(这样,当用户单击按钮时,我可以更改它们的值),但随后我添加了单个按钮的位置信息,这些按钮不再显示。我可以在表单上看到GroupBox的轮廓,以及每侧几百个像素 private void AddQ1() { questionBox = new System.Windows.Forms.GroupBox(); questionBox.Location = new System.Drawing.Point(1200, 250); questionB
private void AddQ1()
{
questionBox = new System.Windows.Forms.GroupBox();
questionBox.Location = new System.Drawing.Point(1200, 250);
questionBox.Size = new System.Drawing.Size(400, 700);
questionBox.Text = "To What extent is this person... striking a pose?";
RadioButton radioButton1;
for (int i = 1; i < 6; i++)//opt 1,2,3,4,5
{
radioButton1 = new System.Windows.Forms.RadioButton();
radioButton1.CheckedChanged += new EventHandler(radioButton_CheckedChanged);
radioButton1.Tag = i.ToString();
radioButton1.Text = i.ToString();
radioButton1.Location = new System.Drawing.Point(1200, (250+(10*i)));
questionBox.Controls.Add(radioButton1);
rbList.Add(radioButton1);
}
Controls.Add(questionBox);
}
private void AddQ1()
{
questionBox=新的System.Windows.Forms.GroupBox();
问题框。位置=新系统。图纸。点(1200250);
问题箱尺寸=新系统图纸尺寸(400700);
questionBox.Text=“此人……摆姿势的程度如何?”;
RadioButton radioButton1;
for(inti=1;i<6;i++)//opt 1,2,3,4,5
{
radioButton1=新的System.Windows.Forms.RadioButton();
radioButton1.CheckedChanged+=新事件处理程序(radioButton\u CheckedChanged);
radioButton1.Tag=i.ToString();
radioButton1.Text=i.ToString();
radioButton1.位置=新系统图纸点(1200,(250+(10*i));
问题框。控件。添加(radioButton1);
rbList.Add(radioButton1);
}
控件。添加(问题框);
}
位置是表示控件左上角与其容器左上角相对的点。
试一试
位置是表示控件左上角与其容器左上角相对的点。 试一试
单选按钮的位置在上述代码中不可见。 location属性与容器相关 看
单选按钮的位置在上述代码中不可见。 location属性与容器相关 看
使用表格布局标签。使用表格布局标签。
radioButton1.Location = new System.Drawing.Point(0, (250+(10*i)));