日期:2014-05-18 浏览次数:20974 次
private void Form1_Load(object sender, EventArgs e) { dataGridView1.Columns.Add(new DataGridViewComboBoxColumn()); List<Item> data=new List<Item>(); for (int i = 0; i < 10; i++) { Item item = new Item(); item.str1 = i.ToString(); item.list.AddRange(new string[] {"sfa","fasa","sfasf" }); item.str2 = (i + 1).ToString(); data.Add(item); dataGridView1.Rows.Add(); DataGridViewComboBoxColumn com = (dataGridView1.Columns[0] as DataGridViewComboBoxColumn); com.DataSource = item.list; } //dataGridView1.DataSource=data; } } class Item { string _str1; List<string> _list = new List<string>(); string _str2; public string str1 { get { return _str1; } set { _str1 = value; } } public List<string> list { get { return _list; } set { _list = value; } } public string str2 { get { return _str2; } set { _str2 = value; } } }