Sorting a column containing a Combobox in a DataGrid

D

Dominique

I have a DataGrid that contains a custom
DataGridTextBoxColumn that can display a DataBound
ComboBox. (See
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q480q)

The underlying value of that column is an Int32 but the
DataGridColumnStyle translates that
value to a text string for display using a DataTable and
a Relation.
This implementation works well for displaying and editing
the data using the textual descriptions.

My problem is that if I permit the user to sort the
DataGrid and they choose to sort on that column that the
DataGrid will automatically sort based on the underlying
Int32 value instead of the textual description. Is it
possible to override this behavior to provide custom
sorting rules so that I could compare the descriptions
myself, or does anybody have any recommendations as to
other methodologies I could examine?

I thank you in advance.
Dominique.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Dominique,

I realize very well that this is a kind of "dirty hack", but you can map
Int32 values to textual values in such a way that the sort order for both of
them will be the same, something like this:

1 = "Albert"
2 = "Dennis"
3 = "Eric"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top