单选按钮在窗体上的定位
本文关键字:定位 窗体 单选按钮 | 更新日期: 2023-09-27 18:37:07
我正在尝试将单选按钮动态添加到表单中(以便我可以在用户单击按钮时更改其值),但随后我为各个按钮添加了位置信息,它们不再出现。我可以在表单上看到 GroupBox 的轮廓,以及每边的几百像素。
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);
}
位置 是表示控件相对于其容器左上角的左上角的点。尝试
radioButton1.Location = new System.Drawing.Point(0, (250+(10*i)));
单选按钮的位置在上面的代码中将不可见。位置属性与容器有关系
看
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.location%28v=vs.110%29.aspx