标签:
/// <summary>
/// 从上到下排列选择行
/// </summary>
/// <param name="dgv"></param>
/// <returns></returns>
public static List<DataGridViewRow> SortedUpDownSelectedRows(this DataGridView dgv)
{
List<DataGridViewRow> lstDgvr = new List<DataGridViewRow>();
if (dgv.SelectedRows.Count == 0)
{
"请先选择属性定义行!".showAlert();
return lstDgvr;
}
lstDgvr = dgv.SelectedRows.Cast<DataGridViewRow>().OrderBy(p => p.Index).Select(p => p).ToList(); ;
return lstDgvr;
}
/// <summary>
/// 从下到上排列选择行
/// </summary>
/// <param name="dgv"></param>
/// <returns></returns>
public static List<DataGridViewRow> SortedDownUpSelectedRows(this DataGridView dgv)
{
List<DataGridViewRow> lstDgvr = new List<DataGridViewRow>();
if (dgv.SelectedRows.Count == 0)
{
"请先选择属性定义行!".showAlert();
return lstDgvr;
}
lstDgvr = dgv.SelectedRows.Cast<DataGridViewRow>().OrderByDescending(p => p.Index).Select(p => p).ToList(); ;
return lstDgvr;
}
标签:
原文地址:http://www.cnblogs.com/swtool/p/5359238.html