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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Iterating through entire databound grid

Thread ID:





16755 Jul 23,2004 09:49 AM UTC Jul 23,2004 11:11 AM UTC WinForms 1
Tags: GridControl
Scott Lundgren
Asked On July 23, 2004 09:49 AM UTC

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

Administrator [Syncfusion]
Replied On 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


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