如何设置值DataGridViewComboBox列? [英] How to set value to DataGridViewComboBox Column?

查看:231
本文介绍了如何设置值DataGridViewComboBox列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何设置值DataGridViewComboBox细胞。我已经与数据源绑定DataGridViewComboBox。但我想通过代码来新的值设置为这个。我写这个

I want to know how to set the value to DataGridViewComboBox cell. I already bind the DataGridViewComboBox with DataSource. But I want to set new value to this by code. I write this.

gvList.Rows[0].Cells[0].value = "Select";



但它遇到错误的格式异常:DataGridViewComboBox单元格值不vlaid 。我怎么能这样做呢?

But it is got error Format Exception: DataGridViewComboBox Cell value is not vlaid . How could I do that?

推荐答案

该错误是由于这样的事实,已绑定一个数据源,并在组合框列,而您指定选择它试图找到相同的数据源其过于约束。
你最好的选择将是同样添加到您绑定到组合框列原来的数据源

The error is due to the fact that you have bound a DataSource to the ComboBox column and while you assign Select its trying to locate the same in the DataSource its bound too. Your best bet will be to add the same to the original DataSource which you bind to the ComboBox column

这篇关于如何设置值DataGridViewComboBox列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆