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

Row/Col index of a DataRowView from a DataRow ?

Hello, I have created a find function for a grid grouping control table. I am able to search the datatable and ‘find’ the correct datarow. I then want to set that cell to the current cell, in the datarow by using :- this.gridgroupcontrol.TableControl.CurrentCell.MoveTo(rownum,colnum); I realise I can get the column number by using:- int colnum = this. gridgroupcontrol.TableDescriptor.VisibleColumns.IndexOf("Column1"); But how do I find out the row index of the displayed rows, from a known datarow? Thanks, David

4 Replies

AD Administrator Syncfusion Team October 4, 2004 12:30 PM UTC

David, Given the row index of the DataRow you can do the following: Record r = Table.UnsortedRecord[dataRowIndex]; int gridRowIndex = Table.DisplayElements.IndexOf(r); Stefan


DL David Llewellyn October 4, 2004 09:41 PM UTC

Hello Stefan, This doesnt seem to work for me. Both Record r = this.gridgroupcontrol.Table.UnsortedRecords[rowindex]; and Record r = this.gridgroupcontrol.Table.Records[rowindex]; return the same record. But the record returned is not the correct one. Obviously the row index is incorrect. What I am doing is searching the underlying datasource for a certain string, which gives me an index. I then want to be able to convert the underlying data source index into a row index for the visible rows. Is there anyway to do this conversion directly without doing further searches for the unsorted table''s row index ?? Thanks, David


AD Administrator Syncfusion Team October 5, 2004 06:29 AM UTC

Here is a try at doing what I think you are describing. It finds a string in the underlying datatable, and then uses the code that Stefan suggested to find the corresponding grid row. It then uses PrepareViewStyleInfo to color the found row. (The grid row count takes into account things like DropArea and Caption and Headers and AddNewRow so the first row from teh datatsource has index 4.) GGCDataTableSearch_8922.zip


DL David Llewellyn October 5, 2004 08:07 PM UTC

Hello Clay, Thanks for the example. That is exactly what I needed. Cheers. David.

Loader.
Live Chat Icon For mobile
Up arrow icon