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

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

Thread ID:

Created:

Updated:

Platform:

Replies:

16711 Jul 22,2004 08:09 AM Jul 22,2004 10:13 AM Windows Forms 2
loading
Tags: Grouping
Daniel Chait
Asked On July 22, 2004 08:09 AM

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 09:30 AM

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 10:13 AM

Thanks - very helpful!

CONFIRMATION

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.

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.

;