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

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

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]; } } } } } }

2 Replies

AD Administrator Syncfusion Team 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


DC Daniel Chait July 22, 2004 02:13 PM UTC

Thanks - very helpful!

Loader.
Up arrow icon