DataGridViewComboBoxColumn - 编辑项目
我正在使用 DataGridView 并有一个 DataGridViewComboBox 类型的列,并且我偶然发现了一个问题。 基本上,根据单元格的值,我想将 .Items 设置为一组特定的字符串,但是当值更改时,我想更改 .Items 列表。 但是这样,我偶尔会从当前被另一个 DataGridViewCell 占用的列表中删除一个字符串,这会更改等于删除项目的所有值,直到我将其重新添加回列表中(在我完成之后)编辑)。
所以基本上,我想知道是否有一种方法可以隐藏组合框下拉列表中的某些项目,这样当选择某个单元格时,他们就无法选择不允许的项目。
谢谢,
劳埃德
I am working with a DataGridView and have a column of type DataGridViewComboBox and I have stumbled across a problem. Basically, depending on the value of the cell, i would like to set the .Items to a certain set of strings, but when the value is changed, i would like to change the .Items list. But with this, I will occasionally remove a string from the list that is currently being occupied by another DataGridViewCell, this changes all the values that were equal to the removed item, until i re-add it back to the list (after i have finished editing).
So basically, I am wondering if there is a way of hiding some of the items from the combo box Drop Down list, so that when a certain cell is selected, they can't choose an item that isn't allowed.
Thanks,
Lloyd
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不是对整个列进行数据绑定,而是对每行的 DataGridViewComboBoxCell 单独进行数据绑定。 这样,一行中的 .items 就不会影响另一行中的 .items。
Instead of databinding the entire column, databind each row's DataGridViewComboBoxCell individually. That way, you don't have .items from one row affecting .items from another row.