毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> net技术 >> 正文

GridControl绑定字段是不一定的如何绑定

更新时间:2012-5-31:  来源:毕业论文

我有一个GridControl,要绑定数据,但绑定字段是不一定的(几个结果集的字段是固定的,但每个都结果集的字段不同),我想知道的是怎么绑定数据上去
给你个列子:用的是第三方控件DevExpress WinFrom开发,用GridControl来绑定数据,应该对你有用

C# code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.BandedGrid;

using bll = PowerData.Mobile.BLL;
namespace PowerData.Mobile.UI.CompanySearch
{
    public partial class UCNine : UCBase
    {
        public UCNine()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 重写父类方法
        /// </summary>
        /// <param name="strEnt_Id"></param>
        /// <param name="strDate"></param>
        public override void LoadInfo(string strEnt_Id, string strDate)
        {
            InitGrid(strEnt_Id, strDate);
        }

        ///初始化表格
        private void InitGrid(string strEnt_Id, string strDate)
        {
           using (DataTable dt = new bll.SewageDischarge().GetNine(strEnt_Id, strDate))
           {
            BandedGridView view = advBandedGridView1 as BandedGridView;
            view.BeginUpdate(); //开始视图的编辑,防止触发其他事件
            view.BeginDataUpdate(); //开始数据的编辑

            view.Bands.Clear();

            //修改附加选项
            view.OptionsView.ShowColumnHeaders = false;                        
            view.OptionsView.ShowGroupPanel = false;                           
            view.OptionsView.EnableAppearanceEvenRow = false;                                
            view.OptionsCustomization.AllowColumnMoving = false;               
            view.OptionsCustomization.AllowColumnResizing = true;            
            view.OptionsCustomization.AllowGroup = false;                     
            view.OptionsCustomization.AllowFilter = false;                   
            view.OptionsCustomization.AllowSort = true;                             
            view.OptionsBehavior.Editable = false;                             

            //添加列标题
            GridBand ent_id = view.Bands.AddBand("ent_id");
            ent_id.Visible = false; //隐藏ID列
            GridBand dec_year = view.Bands.AddBand("dec_year");
            dec_year.Visible = false;
            GridBand pol_code = view.Bands.AddBand("1.固体");
            GridBand pollution_quality = view.Bands.AddBand("2.生产量");
            GridBand pollution_ingredients = view.Bands.AddBand("3.主要成分");
            GridBand ZHLYL = view.Bands.AddBand("综合利用率");//此列包括4.合计,5.综合利用贮存量 几列
            GridBand composite_amount = ZHLYL.Children.AddBand("4.合计");
            GridBand composite_store = ZHLYL.Children.AddBand("5.综合利用贮存量");
            GridBand CZL = view.Bands.AddBand("处置量");//此列包含6.合计,7.符合标准处置量,8。不符合标准处置量,9.其中运往集中处理厂量,10.贮处理往年存量 等几列
            GridBand dealed_amount_quality = CZL.Children.AddBand("6合计");
            GridBand dealed_valid_quality = CZL.Children.AddBand("7.符合标准处置量");
            GridBand dealed_invalid_quality = CZL.Children.AddBand("8.不符合标准处置量");
            GridBand dealed_focus_quality = CZL.Children.AddBand("9.其中运往集中处理厂量");
            GridBand dealed_forward_quality = CZL.Children.AddBand("10.贮处理往年存量");
            GridBand ZCL = view.Bands.AddBand("贮存量");//贮存量包含11.合计,12.符合标准贮存量,13.不符合标准贮存量 等3列
            GridBand store_amount_quality = ZCL.Children.AddBand("11合计");
            GridBand store_valid_quality = ZCL.Children.AddBand("12.符合标准贮存量");
            GridBand store_invalid_quality = ZCL.Children.AddBand("13.不符合标准贮存量");
            GridBand all_store_quality = view.Bands.AddBand("14.历年累积贮存量");
            GridBand pollution_out = view.Bands.AddBand("15.排放量");
            GridBand istransfer = view.Bands.AddBand("16.是否办理转移联单");

[1] [2] 下一页

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。