#region 实现降序排序
class NameDESC : IComparer<Student>
{
public int Compare(Student x, Student y)
{
return y.StudentName.CompareTo(x.StudentName);
}
}
class StudentDESC : IComparer<Student>
{
public int Compare(Student x, Student y)
{
return y.StudentId.CompareTo(x.StudentId);
}
}
#endregion
//姓名降序
private void btnNameDESC_Click(object sender, EventArgs e)
{
if (this.dgvStudentList.RowCount == 0) return;
this.stuList.Sort(new NameDESC());
this.dgvStudentList.Refresh();
}
//学号降序
private void btnStuIdDESC_Click(object sender, EventArgs e)
{
if (this.dgvStudentList.RowCount == 0) return;
this.stuList.Sort(new StudentDESC());
this.dgvStudentList.Refresh();
}