繁体   English   中英

如何将按钮绑定到VB.net数据集中的特定元素?

[英]How to bind a button into a particular element in dataset in VB.net?

我似乎无法弄清楚如何将给定元素绑定到Windows窗体上的按钮。

当我转到控件属性下的DataBindings ,我得到了列的列表,然后单击一个名为ID列。

我得到ItemsBindingSource - ID

从所选列中选择给定元素的正确语法是什么?

您需要在CurrencyManager上设置当前项目:

Dim cm = CType(Me.BindingContext(<DataSource>), CurrencyManager)

' This will change the current record and trigger the update of the Button.
cm.Position += 1

如果它是从SQL表自动生成的源,则应为: Me.TableBindingSource

要基于某些条件选择记录,可以在数据源中找到该项目的位置并将其设置为管理器:

Dim element = cm.List.OfType(Of DataRowView).Single(function(view) view.Item("Column").ToString() = "Value")

cm.Position = cm.List.IndexOf(element)

这里有一些简单的示例:

http://www.akadia.com/services/dotnet_databinding.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM