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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Row/Col index of a DataRowView from a DataRow ?

Thread ID:





19752 Oct 4,2004 02:30 AM UTC Oct 5,2004 08:07 PM UTC WinForms 4
Tags: Grouping
David Llewellyn
Asked On October 4, 2004 02:30 AM UTC

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

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

David Llewellyn
Replied On 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

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

David Llewellyn
Replied On October 5, 2004 08:07 PM UTC

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


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon