Devexpress系列控件功能很强大,使用起来也不太容易,我也是边摸索边使用,如果有时间我会把常用控件的使用方法整理出来的。

【转】Devexpress使用之:GridControl控件(合并表头)

        }



        #region 运行时绑定到实现Ilist接口的数据源

        public class Record
        {
            int id;
            DateTime birth;
            string name, sex, remark;
            float math, chinese, english;
            public Record(int id, string name, string sex, DateTime birth, float math, float chinese, float english, string remark)
            {
                this.id = id;
                this.name = name;
                this.sex = sex;
                this.birth = birth;
                this.math = math;
                this.chinese = chinese;
                this.english = english;
                this.remark = remark;
            }
            public int ID { get { return id; } }
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            public string Sex
            {
                get { return sex; }
                set { sex = value; }
            }
            public DateTime Birth
            {
                get { return birth; }
                set { birth = value; }
            }
            public float Math
            {
                get { return math; }
                set { math = value; }
            }
            public float Chinese
            {
                get { return chinese; }
                set { chinese = value; }
            }
            public float English
            {
                get { return english; }
                set { english = value; }
            }
            public string Remark
            {
                get { return remark; }
                set { remark = value; }
            }


        }

        #endregion


    }
}

 也可以用DataTable进行数据绑定,方法跟上面一致,注意

//模拟几个数据
            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Name");
            dt.Columns.Add("Sex");
            dt.Columns.Add("Birth");
            dt.Columns.Add("Math");
            dt.Columns.Add("Chinese");
            dt.Columns.Add("English");
            dt.Columns.Add("SubTotal");
            dt.Columns.Add("Remark");
            dt.Rows.Add(1, "张三", "", Convert.ToDateTime("1989-5-6"), 115.5f, 101, 96, "");
            dt.Rows.Add(2, "李四", "", Convert.ToDateTime("1987-12-23"), 92, 85, 87, "");
            dt.Rows.Add(3, "王五", "", Convert.ToDateTime("1990-2-11"), 88, 69, 41.5f, "");
            dt.Rows.Add(4, "赵六", "", Convert.ToDateTime("1988-9-1"), 119, 108, 110, "备注行");
            //绑定数据源并显示
            gridControl1.DataSource = dt;
            gridControl1.MainView.PopulateColumns();

 

原文地址:http://www.cnblogs.com/habin/archive/2009/04/24/1442613.html

【转】Devexpress使用之:GridControl控件(合并表头)

        }



        #region 运行时绑定到实现Ilist接口的数据源

        public class Record
        {
            int id;
            DateTime birth;
            string name, sex, remark;
            float math, chinese, english;
            public Record(int id, string name, string sex, DateTime birth, float math, float chinese, float english, string remark)
            {
                this.id = id;
                this.name = name;
                this.sex = sex;
                this.birth = birth;
                this.math = math;
                this.chinese = chinese;
                this.english = english;
                this.remark = remark;
            }
            public int ID { get { return id; } }
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
            public string Sex
            {
                get { return sex; }
                set { sex = value; }
            }
            public DateTime Birth
            {
                get { return birth; }
                set { birth = value; }
            }
            public float Math
            {
                get { return math; }
                set { math = value; }
            }
            public float Chinese
            {
                get { return chinese; }
                set { chinese = value; }
            }
            public float English
            {
                get { return english; }
                set { english = value; }
            }
            public string Remark
            {
                get { return remark; }
                set { remark = value; }
            }


        }

        #endregion


    }
}

 也可以用DataTable进行数据绑定,方法跟上面一致,注意

//模拟几个数据
            DataTable dt = new DataTable();
            dt.Columns.Add("ID");
            dt.Columns.Add("Name");
            dt.Columns.Add("Sex");
            dt.Columns.Add("Birth");
            dt.Columns.Add("Math");
            dt.Columns.Add("Chinese");
            dt.Columns.Add("English");
            dt.Columns.Add("SubTotal");
            dt.Columns.Add("Remark");
            dt.Rows.Add(1, "张三", "", Convert.ToDateTime("1989-5-6"), 115.5f, 101, 96, "");
            dt.Rows.Add(2, "李四", "", Convert.ToDateTime("1987-12-23"), 92, 85, 87, "");
            dt.Rows.Add(3, "王五", "", Convert.ToDateTime("1990-2-11"), 88, 69, 41.5f, "");
            dt.Rows.Add(4, "赵六", "", Convert.ToDateTime("1988-9-1"), 119, 108, 110, "备注行");
            //绑定数据源并显示
            gridControl1.DataSource = dt;
            gridControl1.MainView.PopulateColumns();

 

原文地址:http://www.cnblogs.com/habin/archive/2009/04/24/1442613.html

相关文章: