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.

Getting Object Instance for e.RowIndex

Thread ID:

Created:

Updated:

Platform:

Replies:

38168 Dec 7,2005 12:32 PM Dec 8,2005 10:17 AM Windows Forms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 7, 2005 12:32 PM

I am using a collection of business entity objects as data source for my GDBG. Everything is working my. In QueryCellInfo event I need to get the associated business object for e.RowIndex. How do I get it? If I use the following code I always get the object for the current selected row. CurrencyManager cm = this.gdbgMyGrid.BindingContext[gdbgMyGrid.DataSource, gdbgMyGrid.DataMember] as CurrencyManager; MyObject myObject = (MyObject)cm.Current; Please do help me. VS

Administrator [Syncfusion]
Replied On December 7, 2005 02:01 PM

Try: CurrencyManager cm = this.gdbgMyGrid.BindingContext[gdbgMyGrid.DataSource, gdbgMyGrid.DataMember] as CurrencyManager; MyObject myObject = (MyObject)cm.List[e.RowIndex - 1];

Sebastien Thuilliez
Replied On December 8, 2005 09:08 AM

Clay, is there any way to retrieve the object like you did above, for the displayed rows ... or a way to link displayed elements to CurrencyManager list. Thanks in advance. Seb

Administrator [Syncfusion]
Replied On December 8, 2005 09:30 AM

You can get the grid row indexes of th etop and bottom visible rows using: int topRowIndex = grid.TopRowIndex; int botRowIndex = grid.ViewLayout.LastVisibleRow; To map these to positions in the currencymanager list, you can use grid.Binder.RowIndexToPosition. int topPosition = grid.Binder.RowIndexToPosition(topRowIndex); int botPosition = grid.Binder.RowIndexToPosition(botRowIndex );

Sebastien Thuilliez
Replied On December 8, 2005 09:48 AM

Thanks for your answer Clay. Anyway I didn''t find the TopRowIndex neither the ViewLayout.LastVisibleRow ... are these method coming from GridControl or GridGroupingControl. My mistake, I didn''t gave you any information, more details : I''m using GridGroupingControl with FilterBar .. and due to the filter items I need to only apply computation/process on the displayed rows but the CurrencyManager give me all existing records. Thanks again for your time !

Administrator [Syncfusion]
Replied On December 8, 2005 09:56 AM

If you are using a GridGroupingControl, it is simpler to get the filtered list from the Table.Filteredrecords collection. This collection will hold exactly the records being displayed in the Table. DataRowView drv = this.gridGroupingControl1.Table.FilteredRecords[position].GetData() as DataRowView;

Sebastien Thuilliez
Replied On December 8, 2005 10:17 AM

Like you said, I used MyCustomObject myItem = null; myItem = groupingControl.Table.FilteredRecords[index].GetData() as MyCustomObject; and it works perfectly. It will simplify a lot my source code for this part. Thanks again for your quick and very effective support.

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.

;