zoukankan      html  css  js  c++  java
  • DevExPress GridView 控制列宽度

     /// <summary>
            /// 绑定数据后,分配各列的宽度
            /// </summary>
            private void GridView1_DataSourceChanged(object sender, EventArgs e)
            {
                if (this.winGridViewPager1.gridView1.Columns.Count > 0 && this.winGridViewPager1.gridView1.RowCount > 0)
                {
                    //统一设置100宽度
                    foreach (DevExpress.XtraGrid.Columns.GridColumn column in this.winGridViewPager1.gridView1.Columns)
                    {
                        column.Width = 100;

                  column.AppearanceCell.TextOptions.HAlignment = HorzAlignment.Center;//列内容字体居中
                  column.AppearanceHeader.TextOptions.HAlignment = HorzAlignment.Center; //列头文字居中

                    }
    
                    //可特殊设置特别的宽度
                    SetGridColumWidth("XM", 60);
                    SetGridColumWidth("KCBH", 60);
                    SetGridColumWidth("ZJHM", 150);
                    SetGridColumWidth("KSCX", 60);
                    SetGridColumWidth("KSYY", 60);
                    SetGridColumWidth("YYCS", 60);
                    SetGridColumWidth("JGFS1", 60);
                    SetGridColumWidth("JGFS2", 60);
                    SetGridColumWidth("KSCS", 60);
                    SetGridColumWidth("KSY1", 60);
                    SetGridColumWidth("KSY2", 60);
                    SetGridColumWidth("SFPRINT", 60);
                    SetGridColumWidth("KSJG", 60);
                    SetGridColumWidth("KFXX1", 140);
                    SetGridColumWidth("KFXX2", 140);
                }
            }
    
            private void SetGridColumWidth(string columnName, int width)
            {
                DevExpress.XtraGrid.Columns.GridColumn column = this.winGridViewPager1.gridView1.Columns.ColumnByFieldName(columnName);
                if (column != null)
                {
                    column.Width = width;
                }
            }

    本文来自博客园,作者:云辰,转载请注明原文链接:https://www.cnblogs.com/yunchen/p/13792817.html

  • 相关阅读:
    邻接表(网)
    邻接表(无向图)
    邻接表(无向图)
    邻接表(有向图)
    邻接表(有向图)
    邻接表(无向图)
    邻接表(有向图)
    邻接表(有向图)
    邻接表(网)
    完美解决循环线性操作倒计时无报错
  • 原文地址:https://www.cnblogs.com/yunchen/p/13792817.html
Copyright © 2011-2022 走看看