public Form1 f1 = new Form1();
int p = 150;
int q = 100;
public void add()
{
//CheckBox c = new CheckBox();
//c.Location = new Point(p, q);
//c.Text = f1.sub[0];
//this.Controls.Add(c);
CheckBox chkBox = new CheckBox();
chkBox.Location = new Point(p, q);
chkBox.Text = "Checked";
chkBox.Checked = false;
chkBox.CheckState = CheckState.Checked;
chkBox.CheckedChanged += new EventHandler(chkBox_CheckedChanged);//
this.Controls.Add(chkBox);
chkBox.Text = f1.sub[1];//The problem is here... whatever value I supply
// to sub[] it gives the below mentioned error
}
索引超出範圍。必須是非負數且小於集合的大小。 參數名:指數動態添加複選框
這裏sub[]
是在Form1其中有5個值list<string>
...
然後我應該爲此做些什麼? – Shiv 2010-04-14 08:09:23
我編輯了我的答案。 – 2010-04-14 09:50:04
對不起,但我沒有得到你...... – Shiv 2010-04-14 11:01:48