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
close icon

Iterating through entire databound grid

I am implementing search functionality - given a column, iterate through the (unsorted) column values looking for a particular value. Currently, I am implementing it as follows: n1 = GetTickCount(); for(int i=0; i<_DataGrid.Model.RowCount; i++ ) { if(_DataGrid[i, 1].CellValue.ToString() == strSearchValue ) MessageBox.Show( "found it" ); } n2 = GetTickCount(); MessageBox.Show( (n2 - n1).ToString() ); If the row count is on the order of 4000, my iteration times for a nonexistant record (looping through the entire grid) is ~50-60ms. However, if the row count is on the order of 10000, the total iteration time jumps to between 250 and 400ms, and sometimes much higher. I am aware of the low-resolution of GetTickCount() and accept the jitter in the times. I would like to know why it is performance, which I expected to be directly proportional to row count, slows more than linearly as the row count increases. Secondly, is there anything I can do to improve this (loop trhough the bound datatable, for example?) Thanks, Scott

1 Reply

AD Administrator Syncfusion Team July 23, 2004 11:11 AM UTC

I would not necessarily expect linear behavior even though the search itself is linear. The reason I think this is that more data requires more memory, leaving less free memory, leading to more frequent garbage collection, and general system work load. These factors are not linear in my estimation. Additionally, iterating through the grid requires that the grid get the data from the datasource and then use it in your code. If you cut out the middle man, and iterate through the datasource directly (if this is possible for you), I think you would see noticable preformance improvement. This avoid the firing of grid events like grid.Model.QueryCellInfo that are used to get data from the DataSource. So, I would expect accessing the DataSource directly to perform better. In case you are interested here are a couple of forum threads on Find. The first has a minimal sample using the grid''s default Find/Replace support. The second has a from-scratch Find implemenation. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=14572 http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=8286

Loader.
Live Chat Icon For mobile
Up arrow icon