We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Clearing a grid

Hi

How does one clear a Grid control in WPF? Preferably in a way to reset it to what it was when it first initialized. The WinForms ClearCells method doesn't seem to exist in the GridControl in WPF.

2 Replies

AA Arulraj A Syncfusion Team January 7, 2019 07:03 AM UTC

Hi Jonathan, 
 
Thanks for using Syncfusion products.  
 
The GridControl works on how you define the styles, either through QueryCellInfo or manually setting those styles.  
 
  1. Through QueryCellInfo, you would have an underlying store, which you could simply set it to NULL and reset the Model.RowCount and Model.ColumnCount.
  2. Manually applying styles, then you can clear the internal lists maintained in the Model as,
this.gridControl.Model.VolatileCellStyles.Clear(); 
this.gridControl.Model.Data.Clear(); 
this.gridControl.InvalidateCells(); 
 
 
 
Please let us know if you need any further assistance on this. 

Arulraj A 



JO Jonathan January 7, 2019 08:40 AM UTC

Thanks. The first option solved it.

Loader.
Live Chat Icon For mobile
Up arrow icon