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.

Finding original row in data after a sort

Thread ID:

Created:

Updated:

Platform:

Replies:

62369 Jun 13,2007 02:30 PM Jun 13,2007 03:07 PM Windows Forms 2
loading
Tags: GridControl
Dave Wilkins
Asked On June 13, 2007 02:30 PM

I think this is supposed to be easy. What am I doing wrong?

I have a databound grid and certain cells are colored based on data in the row. Before sorting everything is fine. After clicking a header, the data is resorted but the colors don't change because I'm not relating the new row positions to the data correctly.

Inside PrepareViewStyleInfo event I'm getting the CurrencyManager (cm) and then

DataView dv = cm.List as DataView;
int dataIndex = this.grid.Binder.RowIndexToListManagerPosition(e.RowIndex);

This always returns the same dataIndex for a given e.RowIndex no matter what the sort order is and so the dv[dataIndex].Row is always the same for the same e.rowIndex regardless of sort order. (?)

haneefm [Syncfusion]
Replied On June 13, 2007 03:01 PM

Hi Dave,

The RowIndexToListManagerPosition is required if you have multi-row records as in the Grid\Samples\DataBound\MultiRowRecord sample. Otherwise, you can use the simpler RowIndexToPosition method to retrieve the position. Below is a code snippet

DataView dv = cm.List as DataView;
int position = this.grid.Binder.RowIndexToPosition(e.RowIndex);
DataRow dr = dv[position].Row;

Best regards,
Haneef

Dave Wilkins
Replied On June 13, 2007 03:07 PM

Thanks. I tried that and it seems to work.

You are a star - thanks for getting back to me so quickly.

>Hi Dave,

The RowIndexToListManagerPosition is required if you have multi-row records as in the Grid\Samples\DataBound\MultiRowRecord sample. Otherwise, you can use the simpler RowIndexToPosition method to retrieve the position. Below is a code snippet

DataView dv = cm.List as DataView;
int position = this.grid.Binder.RowIndexToPosition(e.RowIndex);
DataRow dr = dv[position].Row;

Best regards,
Haneef

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.

;