开发者

WPF DataGrid Vs Windows Forms DataGridView

开发者 https://www.devze.com 2023-02-03 07:29 出处:网络
I have experience in WPF and Windows Forms, however have only used the Wind开发者_如何学Cows Forms DataGridView and not the WPF DataGrid (which was only included in .Net 4 or could be added to .Net 3.

I have experience in WPF and Windows Forms, however have only used the Wind开发者_如何学Cows 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..


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.


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.


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";


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


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号