在C#中排序的dataGridView colums? (Windows窗体) [英] Sort dataGridView colums in C# ? (Windows Form)
问题描述
我有我从SQL表绑定一个DataGridView,在DV我有这些属性:ID,名称和价格。当我设置名称列,以自动的SortMode我点击这个专栏中,我可以排序此基础上对名称的第一个字母DV,这样我可以根据自己的第一个字母订购产品(Acumulator,船的头,可口可乐,发动机等)。
I have a datagridview that i bind from an sql table, in that dv i have those attributes: Id, Name and Price. When i set the SortMode of the Name Columns to Automatic and i click on the header of this column i can sort this dv based on the first letter of the Name, this way i can order products based on their first letters ( Acumulator, Boat, CocaCola, Engine etc).
有没有办法发生这件事情不点击列名的头。我找了一些code,将做到这作业时的形式将加载。
Is there a way this thing to happen without clicking the header of the column Name. I am looking some code that will do this job when the form will load.
任何帮助吗?
推荐答案
有就是所谓的排序关于在DataGridView的方法:
There's a method on the DataGridView called "Sort":
this.dataGridView1.Sort(this.dataGridView1.Columns["Name"], ListSortDirection.Ascending);
这将编程排序您的datagridview
This will programmatically sort your datagridview.
这篇关于在C#中排序的dataGridView colums? (Windows窗体)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!