如何使用组合框值c#等于datagridview列值 [英] how to equal a datagridview column values with a combobox value c#
问题描述
您好我需要帮助...我想将searchLookUpEdit1(Dev Component)文本等同于datagridviewcombobox单元格
searchLookUpEdit1。 Text = dgDetail.CurrentRow.Cells [Product]。Value.ToString();
异常发生..
对象引用未设置为对象实例
我正在做对或错以及我称之为代码的事件是什么?
Hello I need a help...i want to equal searchLookUpEdit1 (Dev Component) text into datagridviewcombobox cell
searchLookUpEdit1.Text = dgDetail.CurrentRow.Cells["Product"].Value.ToString();
Exception occurs..
object reference not set to an instance of an object
I am doing right or wrong and which event i call this code?
推荐答案
如果你检查CurrentRow是否为空,你的代码会很酷!
您可以在DataGridView.SelectionChanged事件中使用以下代码:
If you check whether the CurrentRow is null your code will be cool!
You can use the following code in DataGridView.SelectionChanged event:
object obj = dgDetail.CurrentRow;
if (obj != null)
searchLookUpEdit1.Text = dgDetail.CurrentRow.Cells["Product"].Value.ToString();
'对象引用未设置为对象的实例'异常通常来自某些变量没有值。
The 'Object reference not set to an instance of an object' exception usually comes from some variable has no value.
这篇关于如何使用组合框值c#等于datagridview列值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!