gpt4 book ai didi

vb.net 将 datagridview 列类型更改为组合框

转载 作者:行者123 更新时间:2023-12-02 00:05:49 26 4
gpt4 key购买 nike

我可以在运行时将 vb.net 中的 datagridview 中的文本框列更改为组合框列类型吗?我知道这可以在设计时完成,但我想以编程方式完成。

最佳答案

如果您在运行时,您将不得不删除该列,然后添加一个组合框列。确保组合框的项目列表包含数据值,否则将抛出异常。

With DataGridView1
If .Rows.Count = 0 Then Exit Sub
i = Datagridview1.currentrow.index

Dim gridComboBox As New DataGridViewComboBoxCell
gridComboBox.Items.Add("A") 'Populate the Combobox
gridComboBox.Items.Add("B") 'Populate the Combobox
gridComboBox.Items.Add("C") 'Populate the Combobox
.Item(8, i) = gridComboBox
End With

关于vb.net 将 datagridview 列类型更改为组合框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18457873/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com