【问题标题】:Getting the instance of the CurrentRow of a bindingSource获取 bindingSource 的 CurrentRow 的实例
【发布时间】:2015-06-24 02:15:06
【问题描述】:

我想获取 bindingSource 的 CurrentRow 的实例并将其分配给私有变量。

类似:

MatDataSet.KorisnikRow currentRow;    
currentRow = (MatDataSet.KorisnikRow)((DataRowView)korisnikBindingSource.Current).Row;

当然要先创建currentRow变量,否则会弹出Object reference not set to an object错误。但我不知道如何或知道任何解决方法,所以请帮忙。

对不起,糟糕的技术语言。

【问题讨论】:

    标签: c# .net dataset datarow bindingsource


    【解决方案1】:

    您可以检查 BindingSource 是否不为空。

        if (bindingSource.Current != null)
              // your conversion
    

    【讨论】:

    • bindingSource 不为空。 currentRow 是,这就是问题
    • 也许你应该找出究竟是什么空,var rowView = (DataRowView)korisnikBindingSource.Current; var row = rowView.Row; var currentRow = (MatDataSet.KorisnikRow) 行;
    猜你喜欢
    • 2012-12-15
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 2019-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多