zoukankan      html  css  js  c++  java
  • 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;
        }

  • 相关阅读:
    Docker
    springboot与缓存
    微信小程序资源
    Docker的使用及注意事项
    xml解析
    Intellij Idea2018破解教程(激活到2100年)
    natapp内网映射
    HEAD detached from XXX
    JSON语法
    关于苹果、奔驰、杜蕾斯这些红极一时的品牌
  • 原文地址:https://www.cnblogs.com/swtool/p/5359238.html
Copyright © 2011-2022 走看看