// // button2 // Button btn2 = new Button(); btn2.Location = new System.Drawing.Point(349, 240); btn2.Name = "button2"; btn2.Size = new System.Drawing.Size(75, 23); btn2.TabIndex = 3; btn2.Text = "button2"; this.Controls.Add(btn2); }
或者设置chkbox.Location属性
1 2 3 4 5 6 7 8 9
int y = 0; foreach(DataRow dr in dt.Rows) { y += 30; CheckBox chkbox = new CheckBox(); chkbox.Location = new Point(10,y); chkbox.Text = dr["模块名称"].ToString(); gpboxBrow.Controls.Add(chkbox); }