WPF DataGrid 与 Windows 窗体 DataGridView

发布于 2024-10-10 11:04:01 字数 439 浏览 4 评论 0原文

我有 WPF 和 Windows 窗体方面的经验,但是只使用了 Windows 窗体 DataGridView 而不是 WPF DataGrid(据我所知,它仅包含在 .Net 4 中,或者可以从 Codeplex 添加到 .Net 3.5 中)。我即将开发一个应用程序,大量使用这些控件之一来处理大量数据,并且读取性能是 WPF DataGrid 的一个问题,因此我可能会坚持使用 Windows 窗体 DataGridView。是这种情况吗?

我不想使用第三方控件。

对于大量数据,Windows 窗体 DataGridView 是否比 WPF DataGrid 提供显着的性能?

如果我要使用 WPF,我更愿意使用 .Net 3.5S SP1,除非 .Net 4 中的 DataGrid 明显更好?

另外,我想将 ADO 与 DataTable 一起使用,我认为它更适合 Windows 窗体。

I have experience in WPF and Windows Forms, however have only used the Windows Forms DataGridView and not the WPF DataGrid (which was only included in .Net 4 or could be added to .Net 3.5 from Codeplex, I understand). I am about to devlop an app using one of these controls heavily for large amounts of data and have read performance is an issue with the WPF DataGrid so I may stick to the Windows Forms DataGridView.. Is this the case?

I do not want to use a 3rd party control.

Does the Windows Forms DataGridView offer significant performance over the WPF DataGrid for large amounts of data?

If I were to use WPF I would prefer to use .Net 3.5S SP1, unless the DataGrid in the .Net 4 is significantly better?

Also I want to use ADO with DataTable's which I feel is better suited to Windows Forms..

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

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

发布评论

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

评论(5

烟雨扶苏 2024-10-17 11:04:01

根据您的需求,除非您有其他要求引导您使用 WPF,否则我会推荐 WinForms DataGridView。

WPF DataGrid 通过 Codeplex 提供,作为“带外”版本,即这些控件最终将进入 WPF API,但会提前在 Codeplex 上发布,以便我们可以在下一个主要版本之前从它们中受益.NET 版本。您可以使用 .NET 4.0 或 codeplex DataGrid。据我所知,它们是一回事。 WPF DataGrid 与 DataTable 配合得很好。请参阅我的以下文章中的示例:

http://www.codeproject.com/KB/WPF /WPFDataGridExamples.aspx

但是,WPF 框架和视觉效果比 WinForms 稍微重一些。另外,WinForms DataGridView 也非常成熟。

对于非常大的数据集,WinForms DataGridView 有一个 WPF DataGrid 中没有的功能,这对于非常大的网格(数百万行)至关重要,这是一种虚拟模式

: microsoft.com/en-us/library/ms171622.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms171622.aspx

也称为数据虚拟化。在此模式下,您告诉网格数据中有多少行,然后处理事件以填充单元格。这可以很好地扩展。我已将其用于大规模且复杂的网格。

WPF 具有 UI 虚拟化,这是 UI 控件回收的一种形式,但没有数据虚拟化。

希望有帮助。

For your needs, unless you have other requirements that steer you towards WPF, I would recommend the WinForms DataGridView.

The WPF DataGrid was made available via Codeplex, as an 'out of band' release, i.e. these are control that will eventually make their way into the WPF APIs, but are released on codeplex early so that we can benefit from them before the next major .NET release. You can use either the .NET 4.0 or codeplex DataGrid. As far as I know they are one and the same. The WPF DataGrid plays quite nicely with DataTables. See the examples in my following article:

http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx

However, the WPF framework and visuals are slightly more heavyweight than WinForms. Also, the WinForms DataGridView is very mature.

For very large datasets, the WinForms DataGridView has one feature that is not present in the WPF DataGrid, which is vital for very large grids (millions of rows), this is a virtual mode:

http://msdn.microsoft.com/en-us/library/ms171622.aspx

Known also as Data-Virtualization. In this mode, you tell the grid how many rows there are in your data, then handle events to populate the cells. This scales very well. I have used this for massive and complex grids.

WPF has UI virtualization which is a form of UI control recycling, but not data virtualization.

Hope that helps.

征﹌骨岁月お 2024-10-17 11:04:01

对于做出此决定的任何初学者(如我)来说,WindowsForms 非常易于使用。当然,使用 WPF 还有很多其他原因可能会影响您的决定,但如果您的项目主要是 DataGrid,那么 WinForms 就是最佳选择。

For any beginners (like me) making this decision, WindowsForms is tremendously easier to use. Of course, there are a lot of other reasons to use WPF that might influence your decision, but if your project is primarily a DataGrid, then WinForms is the way to go.

假装爱人 2024-10-17 11:04:01

如果您首先填充 DataGrid 的 ItemsSource ,则可以将 DataGrid WPF 用作 DataGridView 。

MyDataGrid.ItemsSource = MySource;
MyDataGrid.Columns[0].Width = 300;
MyDataGrid.Columns[0].Header = "MyName";

You can use a DataGrid WPF as a DataGridView if you at first fill ItemsSource of the DataGrid .

MyDataGrid.ItemsSource = MySource;
MyDataGrid.Columns[0].Width = 300;
MyDataGrid.Columns[0].Header = "MyName";
残花月 2024-10-17 11:04:01

检查 Xceed datagrid for WPF,它比 WPF DataGrid 好得多,但那是 3rdparty,但值得。

Check Xceed datagrid for WPF which is way better than WPF DataGrid but that is 3rdparty but worth it.

墨小沫ゞ 2024-10-17 11:04:01

我认为 WPF DataGrid 更快。但是,当我尝试使用 WPF DataGrid 处理大量数据(大量列(大约 40-50)和行)且具有样式时,它运行缓慢(水平滚动)。来自 3rd 方控件的 DataGrid 工作得更好(我使用 Infragistics XamDataGrid)。

WPF DataGrid much more faster, I think. But when I try to use WPF DataGrid for big amount of data (a lot of columns (about 40-50) and rows) with styles it working slow (horizontal scrolling). DataGrid from 3rd party controls working much better (I use Infragistics XamDataGrid).

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