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

RowIndexToListManagerPosition()

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

5 Replies

AD Administrator Syncfusion Team 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"]));


SL Scott Lundgren 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?


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


AD Administrator Syncfusion Team August 9, 2004 12:20 PM UTC

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


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

Loader.
Live Chat Icon For mobile
Up arrow icon