Quick search in grid

Nov 30, 2010 at 6:03 PM

Objective: to quickly get a line number which contains the definition of key importance. How to make such a search?

Dec 1, 2010 at 3:31 PM

Various possibilities. Depends on the size of the data.


How big is the data set?

Dec 1, 2010 at 3:50 PM
Edited Dec 1, 2010 at 3:54 PM


The data set is small. There are several rows in the table, in which we must quickly find when the event occurs in an asynchronous thread. Need a row index or something like that ... row key

Dec 2, 2010 at 1:25 PM
Edited Dec 2, 2010 at 1:25 PM


grid1[1,0].Value = "LVS";

grid1[2,0].Value = "WDC";



"LVS".Price = 30.41

How search row in grid1 where grid1[x,0].Value == "LVS" ?



Dec 3, 2010 at 8:37 AM

help please, really need

Dec 5, 2010 at 8:01 AM

Why can't you simply loop through all rows all cells and check if the cells contains necessary value?

Dec 5, 2010 at 9:15 AM


Simple iteration is inefficient, because you need to quickly get the desired line number.Processing speed is very critical.

Dec 6, 2010 at 7:51 AM

>Simple iteration is inefficient

Did you test this solution and found that this will be not enough for your case?  having a small dataset makes me doubt that this will be inefficient enough to really slow down your program. The algorithm will be O(n), which will not be that insane.


From my own experience, we have used this algorithm for 5k rows and 20 columns, and that proved to be enough for us, since search did not take any visible amount of time (from end-user experience).

Dec 6, 2010 at 8:01 AM


Thank you very much for your help! I now use an iterative search, but ... My problem is the task requires that a direct access to the row by key (per unit of time can occur very many events, after which you need to update a cell line).
If the new version will be available this functionality, it will be very helpful.
with regards, Oleg