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

Find row index by column value

Hi Clay, I use databound grid and I want to highlight the row with the specific value of the column. Can I get the row index by the column value without looping through all rows? Thanks in advance

3 Replies

AD Administrator Syncfusion Team October 5, 2004 03:08 PM UTC

The grid does have support for a Find/Replace mechanism, but you do have to add code to your project to get this working. There is no built-in Find method. Here is a forum thread with a sample in it. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=14572 Using this technique, the grid is accessing the data in a manner that is firing events. This event processing may slow things down if you have large grids. Here is another sample. It implements a fast FindAll. In this sample, a GridDataBoundGrid with 20000 rows can return all occurrences of a string in less than 100 msecs on my system. It does so by copying the column to an arraylist, and using ArrayList.IndexOf to do the searching. Now in my simple implementation, this requires a full word match. If you wanted more flexibility, instead adding the strings directly to the ArrayList, you could wrap them in an object that has its own Equals method to do whatever custom matching you wanted to do. I suspect this would still be quick. The sample shows both a GridControl and a GridDataBoundGrid. You can set the number of rows, and also whether you want to use the Fast technique or the GridFindReplaceDialogSink technique. Again, it only finds exact matches.

IR Irina October 6, 2004 10:36 AM UTC

Hi Clay, I use your sample #2 with GridFindReplaceDialogSink technique. The only problem is that in your sample when I click ''Find again'' button it finds all strings except the first occurrence of the text which is at row0. When the first occurrence of the text is at row1 – it is okay. Probably because of that, in my GDBG where I have set ListBoxSelectionMode.One it highlights any found row except the case when the found row is the first row. The triangle is on the first row, but it is not highlighted. So to work around the problem I try to check find result: object o = fr.Find(fre); if (o == null) { this.gridDataBoundGrid1.Selections.Add(GridRangeInfo.Row(1)); } But how to fix the problem and be able to find the first row as well? Thanks.

AD Administrator Syncfusion Team October 6, 2004 11:34 AM UTC

Here is a thread that includes a work around for this problem. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=14572

Live Chat Icon For mobile
Up arrow icon