if (dt != null && dt.Rows.Count > 0)
{
//绑定数据源并显示
gridControl1.DataSource = dt;
}
else{
gridControl1.DataSource = null;
}
gridControl1.MainView.PopulateColumns();
//列标题对齐方式
pol_code.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
pollution_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
pollution_ingredients.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
ZHLYL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
composite_amount.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
composite_store.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
CZL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dealed_amount_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dealed_valid_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dealed_invalid_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dealed_focus_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
dealed_forward_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
ZCL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
store_amount_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
store_invalid_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
all_store_quality.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
pollution_out.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
CZL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
ZHLYL.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
//将标题列和数据列对应
view.Columns["ent_id"].OwnerBand = pol_code; //对应列名的字段
view.Columns["ent_id"].Visible = false; //是否隐藏
view.Columns["ent_id"].OptionsColumn.FixedWidth = true; //是否设置固定宽度(当列的宽度为自动时)
view.Columns["ent_id"].Width = 80; //设置当前列的宽度
view.Columns["dec_year"].OwnerBand = pol_code;
view.Columns["dec_year"].Visible = false;
view.Columns["pol_code"].OwnerBand = pol_code;
view.Columns["pol_code"].OptionsColumn.FixedWidth = true;
view.Columns["pol_code"].Width = 180;
view.Columns["pollution_quality"].OwnerBand = pollution_quality;
view.Columns["pollution_quality"].OptionsColumn.FixedWidth = true;
view.Columns["pollution_quality"].Width = 80;
view.Columns["pollution_ingredients"].OwnerBand = pollution_ingredients;
view.Columns["pollution_ingredients"].OptionsColumn.FixedWidth = true;
view.Columns["pollution_ingredients"].Width = 200;
view.Columns["composite_amount"].OwnerBand = composite_amount;
view.Columns["composite_amount"].OptionsColumn.FixedWidth = true;
view.Columns["composite_amount"].Width =80;
view.Columns["composite_store"].OwnerBand = composite_store;
view.Columns["composite_store"].OptionsColumn.FixedWidth = true;
view.Columns["composite_store"].Width = 200;
view.Columns["dealed_amount_quality"].OwnerBand = dealed_amount_quality;
view.Columns["dealed_amount_quality"].OptionsColumn.FixedWidth = true;
view.Columns["dealed_amount_quality"].Width = 80;
view.Columns["dealed_valid_quality"].OwnerBand = dealed_valid_quality;
view.Columns["dealed_valid_quality"].OptionsColumn.FixedWidth = true;
view.Columns["dealed_valid_quality"].Width = 200;
view.Columns["dealed_invalid_quality"].OwnerBand = dealed_invalid_quality;
view.Columns["dealed_invalid_quality"].OptionsColumn.FixedWidth = true;
view.Columns["dealed_invalid_quality"].Width = 200;
view.Columns["dealed_focus_quality"].OwnerBand = dealed_focus_quality;
view.Columns["dealed_focus_quality"].OptionsColumn.FixedWidth = true;
view.Columns["dealed_focus_quality"].Width = 200;
view.Columns["dealed_forward_quality"].OwnerBand = dealed_forward_quality;
view.Columns["dealed_forward_quality"].OptionsColumn.FixedWidth = true;
view.Columns["dealed_forward_quality"].Width = 200;
view.Columns["store_amount_quality"].OwnerBand = store_amount_quality;
view.Columns["store_amount_quality"].OptionsColumn.FixedWidth = true;
view.Columns["store_amount_quality"].Width = 200;
view.Columns["store_valid_quality"].OwnerBand = store_valid_quality;
view.Columns["store_valid_quality"].OptionsColumn.FixedWidth = true;
view.Columns["store_valid_quality"].Width = 200;
view.Columns["store_invalid_quality"].OwnerBand = store_invalid_quality;
view.Columns["store_invalid_quality"].OptionsColumn.FixedWidth = true;
view.Columns["store_invalid_quality"].Width = 200;
view.Columns["all_store_quality"].OwnerBand = all_store_quality;
view.Columns["all_store_quality"].OptionsColumn.FixedWidth = true;
view.Columns["all_store_quality"].Width = 200;
view.Columns["pollution_out"].OwnerBand = pollution_out;
view.Columns["pollution_out"].OptionsColumn.FixedWidth = true;
view.Columns["pollution_out"].Width = 100;
view.Columns["istransfer"].OwnerBand = istransfer;
view.Columns["istransfer"].OptionsColumn.FixedWidth = true;
view.Columns["istransfer"].Width = 200;
view.EndDataUpdate();//结束数据的编辑
view.EndUpdate(); //结束视图的编辑
} } }}
上一页 [1] [2]