WPF DataGrid Vs Windows Forms DataGridView WPF DataGrid Vs Windows Forms DataGridView wpf wpf

WPF DataGrid Vs Windows Forms DataGridView


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