Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF DataGrid Vs Windows Forms DataGridView

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

like image 804
markmnl Avatar asked Jan 06 '11 09:01

markmnl


People also ask

What is the difference between DataGrid and DataGridView?

The DataGrid control is limited to displaying data from an external data source. The DataGridView control, however, can display unbound data stored in the control, data from a bound data source, or bound and unbound data together.

What is the difference between DataGrid and GridView?

The DataGrid and the GridView controls have different event models. The DataGrid control raises single events for operations, while the GridView control is capable of both pre-operation and post-operation events. The GridView control supports the Sorting event that occurs when a field is sorted.

What is DataGridView in WPF?

The DataGrid control enables you to display and edit data from many different sources, such as from a SQL database, LINQ query, or any other bindable data source. For more information, see Binding Sources Overview.

Why do we use DataGridView?

The DataGridView control provides a powerful and flexible way to display data in a tabular format. You can use the DataGridView control to show read-only views of a small amount of data, or you can scale it to show editable views of very large sets of data.


1 Answers

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.

like image 91
ColinE Avatar answered Oct 02 '22 16:10

ColinE