C# winform xml 绑定gridControl so easy处理

        /// <summary>
        /// 绑定GridControl
        /// </summary>
        public void bindGridControl()
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Application.StartupPath + "//AlarmRecord.xml");
            this.gridControl1.DataSource = ds.Tables["ALARMTable"];

            ds.Tables["ALARMTable"].Columns.Count.ToString();

            this.gcALARMTIME.FieldName = ds.Tables["ALARMTable"].Columns["ALARMTIME"].ColumnName;
            this.gcLINENAME.FieldName = ds.Tables["ALARMTable"].Columns["LINENAME"].ColumnName;
            this.gcSTRAINNAME.FieldName = ds.Tables["ALARMTable"].Columns["STRAINNAME"].ColumnName;
            this.gcSPANNAME.FieldName = ds.Tables["ALARMTable"].Columns["SPANNAME"].ColumnName;
            this.gcALARMVALUE.FieldName = ds.Tables["ALARMTable"].Columns["ALARMVALUE"].ColumnName;
            this.gcALARMTYPE.FieldName = ds.Tables["ALARMTable"].Columns["ALARMTYPE"].ColumnName;
            this.gcRecord.FieldName = ds.Tables["ALARMTable"].Columns["Record"].ColumnName;


        }

你可能感兴趣的:(xml,C#,WinForm,dataset)