时间:2019-03-17 标签:c#datagridviewinvirtualmode
假设我有一个包含 A、B、C、D、E 列的数据表。
我得到了一个在虚拟模式下工作的 DataGridView,因为我必须添加一个与 DataTable 未绑定的列。此附加列是一个组合框,它将 A、B、D 列值合并为一个,在用户选择一个项目后,我想读取此选定项目值以进行进一步处理。在方法 DataGridView1_ValueChanged 中,我尝试通过以下方式读取该值:
DataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString()
并且编译器显示异常,我应该使用运算符 new 来启动该对象。 所以,似乎我看到新行已在视觉上添加,但我无法访问它。
我被困在这里:(
Let's say I got a DataTable with columns A,B,C,D,E.
I got a DataGridView that works in virtual mode because I had to add a column that is unbound with DataTable. This additional column is a combobox that combines columns A,B,D values into one, and after user selects an item, than I'd like to read this selected item value for further processing. In method DataGridView1_ValueChanged I try to read that value by:
DataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString()
and compiler shows exception that I should use operator new for initiating the object.
So, seems like I see new row is added visually but I can't access it.
I got stucked in here :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你是在问为什么你不能编译这样的东西:
这看起来很奇怪。你应该能够编译它。
I think you are asking why you can't compile something like this:
Which does seem odd. You should be able to compile that.