我使用这段代码按性别和年龄对网格进行排序,但它不起作用:
this.gridCustomers.Columns["GenderCol"].SortOrder = RadSortOrder.Ascending;
this.gridCustomers.Columns["AgeCol"].SortOrder = RadSortOrder.Descending;
如果我尝试使用Shift键进行排序以进行多重排序,它将起作用。但我需要以编程方式进行。
答案 0 :(得分:1)
使用SortDescriptor怎么样?
SortDescriptor descriptorShipName = new SortDescriptor();
descriptorShipName.PropertyName = "GenderCol";
descriptorShipName.Direction = ListSortDirection.Ascending;
SortDescriptor descriptorFreight = new SortDescriptor();
descriptorFreight.PropertyName = "AgeCol";
descriptorFreight.Direction = ListSortDirection.Descending;
this.radGridView1.SortDescriptors.Add(descriptorShipName);
this.radGridView1.SortDescriptors.Add(descriptorFreight);
有关排序RadGridView的更多信息:http://docs.telerik.com/devtools/winforms/gridview/sorting/setting-sorting-programmatically