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
注解
当控件DataGridView使用属性值为 的Automatic列SortMode进行排序时,排序标志符号将自动显示在列标题中。
从 .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但会阻止标头在单击时更改其外观。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈