c# - 获取 bindingSource 的 CurrentRow 的实例

标签 c# .net dataset datarow bindingsource

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

类似于:

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

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

抱歉技术语言不好。

最佳答案

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

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

关于c# - 获取 bindingSource 的 CurrentRow 的实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29695627/

相关文章:

c# - HttpClient : Unable to read data from the transport connection

c# - 为什么 C# 是开放标准而 .NET 不是?

c# - Web Api 使用 Get 返回 DataSet

python - 如何从 Python 中的 txt 文件中读取数据集?

java - 带 GSI 的 dynamodb 过滤器

c# - C++ 从 C# COM DLL 调用函数

c# - 什么时候可以在 Dispose 中调用 Finalize?

python - 从 csv 文件逐 block 读取和反转数据并复制到新的 csv 文件

c# - 以编程方式从后面的代码关闭 aspx 页面

c# - 在 Windows 7 上运行的 WPF Youtube 应用程序