上网查了查,有好些方法:参考http://www.itzhe.cn/article/20080317/114550.html
写了一个初始化DataGridView中存在DataGridViewComboBox列的方法:
string[] dataListMsg = new string[] {"a","b", "c"};
string[] sLists = new string[] { "1", "2", "3"};
//
TestDataGridView.RowCount = dataListMsg.Length;
//
for (int i = 0; i < TestDataGridView.RowCount; i++)
{
TestDataGridView.Rows[i].Cells[0].Value = dataListMsg[i];
TestDataGridView.Rows[i].Cells[1].Value = true; //为checkBox列
DataGridViewComboBoxCell aCBCell = TestDataGridView.Rows[i].Cells[2] as
DataGridViewComboBoxCell; //为DataGridViewComboBox列
if (aCBCell != null)
{
aCBCell.Items.AddRange(sLists );
aCBCell.Value = sLists[0]; //设置初始值的关键
}
}
希望对大家有帮助,欢迎大家提供更好的方法。