How to dynamically clear grid control of records or data

I can''t seem to find a method to clear the grid control that has been previoulsy populated with data at runtime. All the samples that I''ve seen that populate the grid manually loops thru a recordset and populate the grid, so I can''t really set the grid Datasource property to null (matter of fact, I do not see that property).

Is there a easy way to clear out the grid control that I am not aware of?

2 Replies

AD Administrator Syncfusion Team September 19, 2006 11:45 AM UTC

Hi James,

To clear the grid without modifying the underlying datasource, you can call the GridColumnDescriptorCollection.Clear method

//For the Clear the Column collection in a grid.
this.grid.TableDescriptor.Columns.Clear();

//Reset the Column collection in a grid.
this.grid.TableDescriptor.Columns.Reset()

Sample: http://www.syncfusion.com/Support/user/uploads/GGCUpdate_74da1a58.zip

Best Regards,
Haneef


AD Administrator Syncfusion Team September 19, 2006 11:53 AM UTC

Hi James,

Sorry for the inconvenience caused.

Are you using GridControl? If so, you can use the below code to resolve this

this.grid.Properties.ColHeaders = false;
this.grid.RowCount = 0;
this.grid.ResetVolatileData();

Let me know if this helps.

Thanks,
Haneef

Loader.
Up arrow icon