zoukankan      html  css  js  c++  java
  • DevExpress.XtraEditors.GridLookUpEdit 隐藏列

    第三方控件中,我们经常用GridLookUpEdit来下拉多条数据,有时候需要隐藏某一列,在9.2之前

    Title            this.gle1.Properties.DataSource = dt;
                this.gle1.Properties.ValueMember = "Column1";
                this.gle1.Properties.DisplayMember = "Column2";
                this.gle1.Properties.View.Columns["Column1"].Visible = false;
    这样做,指定列就可以了,但是当控件升级到11.2后,发现Columns里面是没有值的,必须手动赋上列值

    Title            this.gle1.Properties.DataSource = dt;
                this.gle1.Properties.ValueMember = "column1";
                this.gle1.Properties.DisplayMember = "column2";
                string tempStr = string.Empty;  //列名
                this.gle1.Properties.View.Columns.Clear();
                for (int i = 0; i < dt.Columns.Count; i++) {
                    tempStr = dt.Columns[i].ColumnName;
                    DevExpress.XtraGrid.Columns.GridColumn col = this.gle1.Properties.View.Columns.AddField(tempStr);
                    col.VisibleIndex = i;
                    col.Caption = tempStr;

                    if (tempStr.Equals("column1"))
                        col.Visible = false;
                }     

    感觉上这种写法有点丑陋,不知道有没有更好的方法。
  • 相关阅读:
    JavaScript函数式编程——柯里化
    JavaScript使用纯函数避免bug
    ES6入门五:箭头函数、函数与ES6新语法
    图解--二分查找树
    电梯引发的思考
    VIM
    vs 2017
    多线程系列(四):Task
    多线程系列(三):线程池基础
    Docker for windows : 安装Redis
  • 原文地址:https://www.cnblogs.com/hunter98/p/2529892.html
Copyright © 2011-2022 走看看