开发者

Is it possible to force the DataGridView control to order by a value other than cell contents when the user clicks on the column heading?

I'm using c#2.0 and WinForms.

I have a datagridview control, unbound, loading small amounts of data which include 开发者_开发知识库a "Status" relating to a customer.

Now statuses are set up by the user and assigned a sequence number. I would like to display the name of the status in a column on the grid (straight forward enough) but have the customer data in my grid, ordered by the Status's sequence number, not it's name (alphabetically) when the user clicks the "Status" column heading.

Is this possible? How?


You'll want to have a custom sort on your DataGridView. See this article on MSDN.

The sample you'll want to look at is Custom Sorting Using the IComparer Interface. Your RowComparer will check each DataGridViewRow sequence number cell.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜