DataGridViewColumn.SortMode 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置列的排序模式。
public:
property System::Windows::Forms::DataGridViewColumnSortMode SortMode { System::Windows::Forms::DataGridViewColumnSortMode get(); void set(System::Windows::Forms::DataGridViewColumnSortMode value); };
public System.Windows.Forms.DataGridViewColumnSortMode SortMode { get; set; }
member this.SortMode : System.Windows.Forms.DataGridViewColumnSortMode with get, set
Public Property SortMode As DataGridViewColumnSortMode
属性值
一个 DataGridViewColumnSortMode ,指定用于根据列中单元格值对行进行排序的条件。
例外
分配给属性的值与 SelectionMode.
示例
下面的代码示例演示如何使用该 SortMode 属性。
this.dataGridView1.Columns["Priority"].SortMode =
DataGridViewColumnSortMode.Automatic;
Me.dataGridView1.Columns("Priority").SortMode = _
DataGridViewColumnSortMode.Automatic
注解
从 .NET Framework 4.6 开始,当 app.config 文件包含以下条目时,将根据系统 DPI 设置调整排序标志符号的大小:
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
当控件使用属性值为的Programmatic列SortMode进行排序时,必须通过SortGlyphDirection属性自行显示排序标志符号。
默认的 DataGridViewTextBoxColumn 排序模式为 Automatic。 其他列类型的默认排序模式为 NotSortable。
该值 SortMode 不会阻止你以编程方式对列进行排序,尽管其他限制可能适用。 有关更多信息,请参见 Sort 方法。
SortMode属性值NotSortable不会阻止DataGridView.ColumnHeaderMouseClick事件发生,但它将阻止标头在单击时更改其外观。