日期:2014-05-18 浏览次数:20800 次
ComboBox Cmb = new ComboBox(); Cmb.DropDownStyle = ComboBoxStyle.DropDownList; Cmb.Name = dr["name"].ToString(); Cmb.Size = new Size(200, 21); Cmb.Location = new Point(0, 25 * i + 5); Cmb.Items.Add(""); for (int j = 0; j < dtParm.Rows.Count; j++) { Cmb.Items.Add(dtParm.Rows[j][1].ToString()); } panel2.Controls.Add(Cmb);
ComboBox Cmb = new ComboBox(); Cmb.Items.Add(1); Cmb.Items.Add(2); Cmb.Items.Add(3); Cmb.Items.Add(4); Cmb.SelectedIndexChanged += (o, i) => { Cmb.Items.Remove(Cmb.SelectedItem);//索引发生变化时,移除选中当前项目 }; this.Controls.Add(Cmb);
------解决方案--------------------
Cmb还没panel2.Controls.Add(Cmb);
就想RemoveAt?
------解决方案--------------------