C#/Winforms: sorting a datagridview by a column that is not part of the DataSource

cdatagridviewdatasourcewinforms

I have a datagridview that has its datasource linked to a databinding from a database. All the columns are sortable by doubleclicking the header.

Now I added one extra column by hand that just contains numbers. Strangely I cannot sort the datagridview by this column. If I doubleclick the header nothing happens.

I have set sortmode to automatic.

What am I missing here?

Best Answer

This link should be the answer you need: Sorting an unbound column

Basically what you're trying to do is not supported. You have to handle the sorting yourself by keeping track of the direction and handle the sorting by using the SortGlyph.

Good luck, hope this helps.