0
votes

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?

2

2 Answers

3
votes

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.

1
votes

If you are using Visual Studio:

You need to add the column in the dataset designer not the data grid.

From the data set designer, right click on the table adapter that your binding to, and add the columns desired.

I had to close visual studio and reopen it for it to update properly

Then go back to the data grid and add the new columns from the list.