foreach (DataGridViewRow row in this.dgvQueryAsk.Rows)
{
DataTable dtGet = ABC.getSupplyInfoForCombox(Convert.ToInt32(row.Cells["SerID"].Value));
if (dtGet.Rows.Count > 0)
{
object[] tels = new object[dtGet.Rows.Count];
for (int i = 0; i < dtGet.Rows.Count; i++)
{
tels[i] = dtGet.Rows[i][0];
}
this.BindCb(row, tels);
}
//DataTable employeeDataTable = objReSaleQueryDal.getEmployeeDataTableForGrid();
//if (employeeDataTable.Rows.Count > 0)
//{
// object[] telsemployee = new object[employeeDataTable.Rows.Count];
// for (int i = 0; i < employeeDataTable.Rows.Count; i++)
// {
// telsemployee[i] = employeeDataTable.Rows[i][0];
// }
// this.BindCbEmployee(row, telsemployee);
//}
this.BindCb_ColSupplyerLevel(row, new object[] { "--请选择--", "AB", "BC", "CE" });
}
}
//private void BindCbEmployee(DataGridViewRow row, object[] tels)
//{
// DataGridViewComboBoxCell aCBCell = row.Cells["ColEName"] as DataGridViewComboBoxCell; //为DataGridViewComboBox列
// if (aCBCell != null)
// {
// aCBCell.Items.AddRange(tels);
// aCBCell.Value = tels[0]; //设置初始值的关键
// }
//}
本文展示了一个使用C#编写的示例代码,该代码演示了如何遍历DataGridView中的每一行,并为特定列的DataGridViewComboBoxCell填充数据。通过调用不同的方法获取数据源并将其绑定到组合框中。
1640

被折叠的 条评论
为什么被折叠?



