如何获取绑定到现有DataTable的DataGridView以显示DropDownList列?

时间:2012-09-25 17:13:08

标签: c# drop-down-menu datagridview datatable datagridviewcombobox

我正在尝试创建具有以下特征的DataGridView: - 它的DataSource是我创建的DataTable,里面有几列。 - DataGridView中的一列显示我填充的DropDownList(对应于我的DataTable中已有的列)。 - DropDownList中选择的值填充DataTable中的基础列。

到目前为止,我可以通过将DataGridView.AutoGenerateColumns属性设置为false,然后通过循环遍历DataTable中所有非DropDownList列的列并使用DataGridViewComboBoxColumn(设置该列的列)来手动创建列。 DataSource属性到我创建的列表)我想要作为DropDownList的列。

然而,这似乎既凌乱又冗长(几乎不可能概括)。有没有更好的方法来实现同样的结果?

0 个答案:

没有答案