从 DataView C# 中获取价值
如何从 DataView.CurrentItem 查找某些列的值。
How to find a value of some column from DataView.CurrentItem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何从 DataView.CurrentItem 查找某些列的值。
How to find a value of some column from DataView.CurrentItem.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
正如 Paul 在评论中指出的那样,
DataView
类中没有CurrentItem
成员。如果您知道该项目的索引,则可以通过其名称访问列,如下所示:
同样,如果您有一个
DataRowView
实例(DataRow
的视图) >),你可以这样做:编辑:我刚刚注意到你问题上的 WPF 标签...也许你正在谈论
CollectionView
,而不是DataView
?CollectionView
本身没有“列”,但它可以在GridView
或DataGrid
(两者都有列)中表示。它只是对象集合的视图。要访问当前对象的特定字段或属性,有两个主要选项:CurrentItem
转换为该类型,然后直接访问您想要的成员。如果As Paul pointed out in his comment, there is no
CurrentItem
member in theDataView
class.If you know the index of the item, you can access a column by its name as shown below :
Similarly, if you have an instance of a
DataRowView
(a view of aDataRow
), you can do that :EDIT: I just noticed the WPF tag on your question... perhaps you're talking about a
CollectionView
, notDataView
?CollectionView
doesn't have "columns" per se, but it can be represented in aGridView
orDataGrid
(which both have columns). It's just a view over a collection of objects. To access a specific field or property of the current object, there are two main options :CurrentItem
to that type, and directly access the members you need