DevExpress gridControl控件动态绑定列 zt

DataTable dt = =Query.GetCustome=(ref customColumnCount);

            

            //绑定列

            gridView.Columns.Add(new GridColumn() { Name = "NoCHK", FieldName = "NoCHK", Caption = "选择", VisibleIndex =0});

            gridView.Columns.Add(new GridColumn() { Name = "No", FieldName = "No", Caption = "No", Visible = false });

            gridView.Columns["TestNo"].OptionsColumn.AllowEdit = false;

            gridView.Columns.Add(new GridColumn() { Name = "NAME", FieldName = "NAME", Caption = "名称", VisibleIndex=2 });

            gridView.Columns["NAME"].OptionsColumn.AllowEdit = false;

gridControl.DataSource = dt;

            //自动列宽,会出现横向滚动条

            gridView.OptionsView.ColumnAutoWidth = false;

            

            //自动列宽

            gridView.BestFitColumns();
VisibleIndex =0这个要有的,如果没有就不会显示,

你可能感兴趣的:(DevExpress)