我想動態添加單選按鈕到表單(所以我可以在用戶單擊按鈕時更改它們的值),但是我添加了它們不再出現的單個按鈕的位置信息。我可以在窗體上看到GroupBox的輪廓,以及每邊數百個像素。RadioButton定位在表格
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);
}
使用表格佈局標籤。 –