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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

RowIndexToListManagerPosition()

Thread ID:

Created:

Updated:

Platform:

Replies:

17358 Aug 6,2004 01:09 PM UTC Aug 9,2004 12:48 PM UTC WinForms 5
loading
Tags: GridControl
Scott Lundgren
Asked On August 6, 2004 01:09 PM UTC

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 02:58 PM UTC

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 03:27 PM UTC

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 03:34 PM UTC

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 12:20 PM UTC

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

Administrator [Syncfusion]
Replied On August 9, 2004 12:48 PM UTC

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.

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

;