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

    感觉上这种写法有点丑陋,不知道有没有更好的方法。
  • 相关阅读:
    HUST 1372 marshmallow
    HUST 1371 Emergency relief
    CodeForces 629D Babaei and Birthday Cake
    CodeForces 629C Famil Door and Brackets
    ZOJ 3872 Beauty of Array
    ZOJ 3870 Team Formation
    HDU 5631 Rikka with Graph
    HDU 5630 Rikka with Chess
    CodeForces 626D Jerry's Protest
    【POJ 1964】 City Game
  • 原文地址:https://www.cnblogs.com/hunter98/p/2529892.html
Copyright © 2011-2022 走看看