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.

RowIndexToListManagerPosition()

Thread ID:

Created:

Updated:

Platform:

Replies:

17358 Aug 6,2004 09:09 AM Aug 9,2004 08:48 AM Windows Forms 5
loading
Tags: GridControl
Scott Lundgren
Asked On August 6, 2004 09:09 AM

I have a datatable bound to a gdbg. I can use RowIndexToListManagerPosition() to get the index in the underlying datatable, and this works as I expect, unless I look at a sorted view of the table by clicking on the column headers in the gdbg. How can I get at the underlying view or otherwise get the actual underlying datatable index from the current row index, taking sorting into account. I''d also like to do this in reverse. ListManagerPos_6265.zip

Administrator [Syncfusion]
Replied On August 6, 2004 10:58 AM

You can use this code. int nRowPos = _DataGrid.CurrentCell.RowIndex; int pos = _DataGrid.Binder.RowIndexToPosition(nRowPos); CurrencyManager cm = (CurrencyManager) _DataGrid.BindingContext[_DataGrid.DataSource, _DataGrid.DataMember]; DataRowView drv = (DataRowView)cm.List[pos]; MessageBox.Show(string.Format("{0} {1}", drv["1"], drv["2"]));

Scott Lundgren
Replied On August 6, 2004 11:27 AM

Thanks - that works well. I also need to do the reverse - given a row index in the underlying datatable, what is the row index in the grid?

Administrator [Syncfusion]
Replied On August 6, 2004 11:34 AM

If you get the position from the CurrencyManager of the sorted grid, then you can use: _DataGrid.Binder.PositionToRowIndex.

Administrator [Syncfusion]
Replied On August 9, 2004 08:20 AM

How do I: >get the position from the >CurrencyManager of the sorted grid ?

Administrator [Syncfusion]
Replied On August 9, 2004 08:48 AM

If you are interested in only the current position, then you can use cm.Position. If you are interested in some arbitary DataRowView in the cm.List, then you would have to loop through the list looking for the item (or maybe use DataView.Find if you have things sorted on some key you can use as a lookup value)

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.

;