如何获取绑定源中选定的行

发布于 2024-08-17 21:00:35 字数 322 浏览 7 评论 0原文

如何获取绑定源中选定的行。 我认为这就是解决方案:

       DataRow row = ((DataRowView)bindingSource1.Current).Row;

但我仍然得到整个 datagridview 如果我站在“行”上,在运行应用程序时打开树,我可以选择 Itemarray 并查看所选数据。但不知道如何改变这条线

       DataRow row = ((DataRowView)bindingSource1.Current).Row;

有人能帮我解决这个问题吗?

How to fetch the selected row in a bindingsource.
I thought this was the solution:

       DataRow row = ((DataRowView)bindingSource1.Current).Row;

But I still get the whole datagridview
If I stand on 'row' open the tree while I'm running my application I can select the Itemarray and see the selected data. but dont know how the change this line

       DataRow row = ((DataRowView)bindingSource1.Current).Row;

Could somebody help me solve this problem ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

三岁铭 2024-08-24 21:00:35
object row = ((DataRowView)bindingSource1.Current).Row[i];

i 是列索引

object row = ((DataRowView)bindingSource1.Current).Row[i];

i is the column index

太阳公公是暖光 2024-08-24 21:00:35

没关系,我是这样解决的
对象[] obj = ((DataRowView)bindingSource1.Current).Row.ItemArray;

Never mind, I solved it like this
object[] obj = ((DataRowView)bindingSource1.Current).Row.ItemArray;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文