• C# devExpress GridControl 行中行 子行 多级行


    在工作中经常会碰到需要做行中行,多级行的情况,不熟的情况下,我也只能试着实现.


    命名空间

    using DevExpress.XtraEditors.Repository;
    using System.Data.SqlClient;
    

    实现代码

    一下实现的也只是一个demo,大家不要拘泥于数据

       DB db = new DB();
                DataSet ds = new System.Data.DataSet();
                SqlCommand comm2 = new SqlCommand(sql, db.getSqlConnection());  //db.getSqlConnection() 返回一个sqlConnection 对象
                SqlCommand comm3 = new SqlCommand(sql1, db.getSqlConnection());
                SqlCommand comm4 = new SqlCommand(sql2, db.getSqlConnection());
                SqlDataAdapter da2 = new SqlDataAdapter(comm2);
                SqlDataAdapter da3 = new SqlDataAdapter(comm3);
                SqlDataAdapter da4 = new SqlDataAdapter(comm3);
    
                da2.Fill(ds,"emp");
                da3.Fill(ds,"job");
                da4.Fill(ds,"re");
    
                this.treeListLookUpEdit1TreeList.DataSource = ds;
    
                DataColumn parentColumn = ds.Tables["emp"].Columns["empNum"];
                DataColumn childColumn = ds.Tables["job"].Columns["empNum"];
                DataColumn secondChild = ds.Tables["re"].Columns["empNum"];
    
                DataRelation relCustOrder;
                relCustOrder = new DataRelation("对应工作", parentColumn, childColumn);
                DataRelation job;
                job = new DataRelation("部门调整", childColumn, secondChild);
                ds.Relations.Add(relCustOrder);
                ds.Relations.Add(job);
                this.gridControl1.DataSource = ds.Tables["emp"];
    
    
    实现效果如下:


  • 相关阅读:
    Web API DataContract DataMember Serializable简单解释
    v-bind和v-on
    CSS大写转换
    Web API 实体显示注释
    Web API性能优化(一)压缩
    时间序列化问题
    border 0px和border none的区别
    CSS实现单行、多行文本溢出显示省略号
    MySQL防止重复插入记录SQL
    mvc和webapi同一解决方案调试办法
  • 原文地址:https://www.cnblogs.com/xiaxiaolu/p/4367154.html
Copyright © 2020-2023  润新知