| |
|
How to clear the data from a DataGrid using WPF in C#
|
| |
|
|
| |
| I implemented some filtering into one of my DataGrids which
required that a reset the initial result set. With a single line of code
you can empty out the contents of the DataGrid.
|
| |
datagridResults.ItemsSource = null;
|
| |
|
Once I reset the contents to empty, I could then add the filtered content
back into the DataGrid using the ListCollectionView.Filter method.
|
| |
|
NOTE: I populated a DataTable with the results of the filter method.
Each time I did a filter I needed to clear the filtered results in the
DataTable, but did not want to reset the DataTable column structure.
I achieved this by using the Clear method of the DataTable.
|
| |
MyDataTable.Clear();
|
| |
|
|
| |
|
|
| |
|
|
| |
| |
| Posts: 103 |
| Comments:
86 |
| Fundamentals:
13 |
| |
 |
| |
| |
|
| |
 |
| |
 |
| |
 |
| |
|
| 2011 December (2) |
| 2011 November (6) |
| 2011 October (7) |
| 2011 September (7) |
| 2011 August (9) |
| 2011 July (9) |
| 2011 June (8) |
| 2011 May (9) |
| 2011 April (7) |
| 2011 March (9) |
| 2011 February (8) |
| 2011 January (8) |
| 2010 December (7) |
| 2010 November (8) |
| 2010 October (4) |
| |
| |
|
| |
|
|
| |
| |
|
The sample code on this website is provided to illustrate a concept and should not be used in
applications or Web sites without proper professional consultation, as it may not illustrate
the safest coding practices. I assume no liability for incidental or consequential damages
should the sample code be used for purposes other than as intended.
|
| |
|
| | | |