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

Fastest way to set a cell value

Clay, Is the a faster way to set a cell value in the GDBG other than this.grid[1,1].Text? Regards, Thomas

5 Replies

AD Administrator Syncfusion Team June 23, 2005 10:15 PM UTC

The most effiecient way to do it is to directly access the datasource. eg, this.dataTable1.Rows[0]["Col0"] = somevalue;


AD Administrator Syncfusion Team June 24, 2005 05:12 AM UTC

Ok, thanks. I case of a unbound coulumn? I''m checking the time with a code profiler and see that the value modification of a cell takes a bit a long time. Regards, Thomas


AD Administrator Syncfusion Team June 24, 2005 08:13 AM UTC

In an unbound grid that stores data in the GridControl.Data object, then setting the value using grid.SetCellInfo with the proper flags set, or directly accessing grid.Data[row, col] as below, will avoid events and perform 5-10 faster that just directly indexing the GridControl.
GridStyleInfo style = null;
if(grid.Data[row, col] != null
{
   style = new GridStyleInfo(grid.Data[row, col]);
}
else
{
   style = new GridStyleInfo();
}
style.Text = "something";
grid.Data[row, col] = style.Store;


AD Administrator Syncfusion Team June 24, 2005 11:53 AM UTC

Thanks Clay. Now, I have to set the Tag property of the header cell in a GDBG. Did you see any problem when I use this code in my implementation: GridStyleInfoStore store = this.Model.Data[0, 0]; store.SetValue( store.FindStyleInfoProperty( "Tag" ), "Error" ); The performance is great this way. Regards, Thomas


AD Administrator Syncfusion Team June 24, 2005 01:48 PM UTC

I think this should be OK. You could not venture past row 0 (and probably column 10) as there is no storage allocated in the Data object past those limits.

Loader.
Live Chat Icon For mobile
Up arrow icon