110,499
社区成员
发帖
与我相关
我的任务
分享
xxxxxx{
class MyRowComparer : System.Collections.IComparer
{
public int Compare(object x, object y)
{
DataGridViewRow a = (DataGridViewRow)x;
DataGridViewRow b = (DataGridViewRow)y;
int result;
result = a.Cells[1].Value.ToString().CompareTo(b.Cells[1].Value.ToString());
if (result != 0)
return result;
return a.Cells[0].Value.ToString().CompareTo(b.Cells[0].Value.ToString());
}
}
dgv.Sort(new MyRowComparer());
}