DataGridViewComboBoxColumn在运行时...... [英] DataGridViewComboBoxColumn in run time ......

查看:115
本文介绍了DataGridViewComboBoxColumn在运行时......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我在运行时创建了一个DataGridViewComboBoxColumn,找到了选定的项目,但是当我在项目中编写此代码时,它返回null

Hi I created a DataGridViewComboBoxColumn in run time and I found the selected item, but when I wrote this code in my project it returns null

datagridview1.Rows[i].Cells[0].Value.ToString();



请帮助我



Please Help Me

推荐答案

通过它返回null",我假设您的意思是您收到了Null引用异常-ToString无法返回null.

问题是,其余的代码是什么样的?

您说要在运行时创建它-是否输入了任何值?您是否为组合框设置了一个值或将其保留为空白下拉菜单?
您将代码放在哪里?在SelectionChanged事件中?如果是这样,那么在首次创建DataGridView时,您将获得一个事件(和空引用).
By "it returns null" I assume that you mean you get a Null Reference exception - ToString cannot return null.

The question is, what does the rest of your code look like?

You say you are creating this at run time - did you put any values in? Did you set a value for the combobox or leave it as a blank drop down?
Where did you put that code? In the SelectionChanged event? If so, then you will get an event (and a null reference) when the DataGridView is first created.


这篇关于DataGridViewComboBoxColumn在运行时......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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