views:

25

answers:

1

Scenario: Winforms DataGrid control in which one of the columns is a comboBox control (NB: not datagridview).

The DataSource for the DataGrid is a dataView, with essentially two ID fields, lets say OrderID, CurrencyID; i show the CurrencyName in the combo and grid, but store the CurrencyID. So, the DisplayMember for the combobox is CurrencyName and the ValueMember is CurrencyID.

Problem: When user sorts the datagrid on column Currency (by clicking on Header of the grid), the sorting happens on CurrencyID (which is understandable to me since column is actually bound to CurrencyID), however for the user sorting must happen on CurrencyName.

Pretty standard problem, surely someone has done it before, i may have even done so myself, just gone totally blank now:-( Help.

A: 

I had exactly this problem and posted on my blog about it:

http://adamhouldsworth.blogspot.com/2010/01/bound-datagridview-sorting.html

Hope this helps.

Adam