How to: Set the Sort Modes for Columns in the Windows Forms DataGridView Control

In the DataGridView control, text box columns use automatic sorting by default, while other column types are not sorted automatically. Sometimes you will want to override these defaults. For example, you can display images in place of text, numbers, or enumeration cell values. While the images cannot be sorted, the underlying values that they represent can be sorted.

In the DataGridView control, the SortMode property value of a column determines its sorting behavior.

The following procedure shows the Priority column from How to: Customize Data Formatting in the Windows Forms DataGridView Control. This column is an image column and is not sortable by default. It contains actual cell values that are strings, however, so it can be sorted automatically.

To set the sort mode for a column

This example requires:

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft