• DataGridView选中行按从上到下或从下到上排序


        /// <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;
        }

  • 相关阅读:
    python yield yield from
    python isinstance()与type()的区别
    python isinstance用法
    python 展开嵌套的序列
    python getmtime() 最近修改文件内容的时间
    python getctime() 文件最后一次的改变时间
    python getatime() 查看文件的访问时间
    python模拟随机游走
    getopt例子
    matplotlib 代码风格
  • 原文地址:https://www.cnblogs.com/swtool/p/5359238.html
Copyright © 2020-2023  润新知