DataTable的新DataView与DefaultView [英] New DataView vs. DefaultView of a DataTable

查看:342
本文介绍了DataTable的新DataView与DefaultView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么要构造一个新的 DataView 而不是使用 DataTable的 DefaultView C#中的



创建新的 DataView 的方案是什么? / p>

两者的优点和缺点是什么?



var dataView = new DataView dataTable);



vs



var dataView = dataTable.DefaultView;

解决方案

DefaultView 具有默认存在的优点,作为名称



其他 DataViews 具有允许您将其中几个准备就绪并在并行使用的优势



S o您可以以不同的方式过滤排序 3,并绑定3个不同的控件,例如三个DataGridViews DGV 项目 code> ComboboxCell 给他们独立



这篇文章


dataview是datatable上的一个视图,有点像sql视图。它允许
过滤和排序行 - 通常用于绑定到Windows窗体
控件。另外,可以自定义一个DataView,以从DataTable呈现一个
的数据子集。此功能允许您将
两个控件绑定到同一个DataTable,但显示不同的
版本的数据。



Why would you construct a new DataView instead of using the DefaultView of the DataTable in C#?

What are the scenarios creating a new DataView is preferable?

What are the advantages and disadvantages of both?

var dataView = new DataView(dataTable);

vs

var dataView = dataTable.DefaultView;

解决方案

The DefaultView has the advantage of being there already by default, as the name implies.

Additional DataViews have the advantage of allowing you to keep several of them ready and in use in parallel.

So you can filter and sort 3 of them in different ways and bind 3 different controls, e.g. three DataGridViews or a DGV and the Items of a ComboboxCell to them independently.

Quoting from this post:

A dataview is a view on a datatable, a bit like a sql view. It allows you to filter and sort the rows - often for binding to a windows form control. Additionally, a DataView can be customized to present a subset of data from the DataTable. This capability allows you to have two controls bound to the same DataTable, but showing different versions of the data.

这篇关于DataTable的新DataView与DefaultView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆