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

Equivalent of TableDescriptor.ColIndexToField() but for Rows--> Records ?

Thread ID:





16711 Jul 22,2004 12:09 PM UTC Jul 22,2004 02:13 PM UTC WinForms 2
Tags: Grouping
Daniel Chait
Asked On July 22, 2004 12:09 PM UTC

Basically I want to handle a key event in a gridgrouping control and do some stuff with the current selection. However I cant see where I can translate these row/col indexes to actual record indexes. See the following for where I''m code going with this: private void TableControl_KeyDown(object sender, KeyEventArgs e) { if ( e.KeyCode == Keys.D && e.Modifiers == Keys.Control ) { if ( gridGroupingControl1.TableControl.Selections.Count == 1 ) { foreach ( GridRangeInfo info in gridGroupingControl1.TableControl.Selections.Ranges ) { for ( int j=info.Left; j <= info.Right; j++ ) { int fieldIndex = gridGroupingControl1.TableDescriptor.ColIndexToField(j); for ( int i=info.Top; i <= info.Bottom; i++ ) { //I''m looking for something like: //int recordIndex = gridGroupingControl1.TableDescriptor.RowIndexToRecord(i); //Record record = gridGroupingControl1.TableModel.Table.Records[recordIndex]; } } } } } }

Administrator [Syncfusion]
Replied On July 22, 2004 01:30 PM UTC

Daniel, there is a one-to-one relation between rowindex and the Table.DisplayElements collection. If you have a rowIndex you can get the element that is displayed at that row with Element el = Table.DisplayElements[rowIndex]; The record the element belongs to will be Record r = el.ParentRecord; The record position in the table can then be determined with int index = Table.Records.IndexOf(r); or the record position in the underlying source list with int orginalIndex = Table.UnsortedRecords.IndexOf(r) BTW - if you have an element and want to know the rowindex it is displayed at you can do this: int rowIndex = Table.DisplayElements.IndexOf(el); Stefan

Daniel Chait
Replied On July 22, 2004 02:13 PM UTC

Thanks - very helpful!


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