Is it possible to force the DataGridView to order on a value other than the cell content when the user clicks on the column header?

I am using C # 2.0 and WinForms.

I have a datagridview control unbound, loading small amounts of data that includes a "status" related to the client.

Now the statuses are user configurable and a sequential number is assigned. I would like to display the status name in a column in a grid (straight forward enough), but have customer data in my grid sorted by status ordinal, not name (alphabetically) when the user clicks the Status button "column header.

Is it possible? How?

+2


source to share


1 answer


You want to have your own datatype in your DataGridView. See this article on MSDN.



The sample you want to look at is a selective sort using the IComparer interface. Your RowComparer will check every cell in the DataGridViewRow data sequence.

+2


source







All Articles