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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to clear the GridControl?

Thread ID:

Created:

Updated:

Platform:

Replies:

131582 Jul 18,2017 05:39 AM UTC Jul 19,2017 11:56 AM UTC Windows Forms 1
loading
Tags: GridControl
JeeNew
Asked On July 18, 2017 05:39 AM UTC

I have a grid control where I am trying to update the table when I have a new set of values that I want to display on button click but I am unable to update the grid control with new values, I still see the old values.
I found a work around but I am not satisfied with that. The work around is to set the RowCount to 0 on every run.
Is there a better way to handle this scenario?
Thanks in advance!

Mohanraj Gunasekaran [Syncfusion]
Replied On July 19, 2017 11:56 AM UTC

Hi JeeNew, 

Thanks for using Syncfusion product. 

Suggestion 1 

In order to update the GridControl by new set of values, you can use the PopulateValues method and then you should refresh the GridControl using Refresh method. Please refer to the below code example, 

Code example 
DataTable data = new DataTable(); 
CreateTable(data); 
//Repopulate the grid. 
this.gridControl1.PopulateHeaders(GridRangeInfo.Cells(0, 1, gridControl1.RowCount, gridControl1.ColCount), data); 
this.gridControl1.PopulateValues(GridRangeInfo.Cells(1, 1, gridControl1.RowCount, gridControl1.ColCount), data); 
this.gridControl1.Refresh(); 
 
 
 
Suggestion 2 
If you would like to update the specific cell value in button click. You can use the CellValue property. Please refer the below code example and the KB link, 

Code example 
this.gridControl1[1, 2].CellValue = "John"; 
 
 
 
Suggestion 3 
In order to clear the grid cell values, you can use the ClearCells method. Please refer to the below code example and the sample, 

Code example 
this.gridControl1.ClearCells(GridRangeInfo.Table(), true); 
 
 
Sample link: GridControl 
 
Regards, 
Mohanraj G 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;