【新手】DevExpess的GridView嵌套表格
来源:互联网 发布:怎样导出数据库 编辑:程序博客网 时间:2024/06/05 07:32
嵌套表格效果图一
嵌套表格效果图二
可视化编辑界面,一个gridControl1(GridControl),下面是MainView(名为gridView_dept的GridView),再添加子层Level1(也是个GridView,名为gridView_Module)
编辑两个GridView的各个Columns,把FieldName字段与数据库表的名称对应好
代码:
public DataSet ds = new DataSet(); public DataTable dtModule; public DataTable dtDept; private void onLoad(object sender, EventArgs e) { dtDept = BLLUtil.GetTableData(TableField.T_FORM.T_NAME, string.Empty);//父表装进DataTable dtModule = BLLUtil.GetTableData(TableField.T_FORM_QUESTION.T_NAME, string.Empty);//子表装进DataTable ds.Tables.Add(dtDept); ds.Tables.Add(dtModule); //下面映射主从关系Add(Level1是名称,会显示在子表的标签处,有文章说这个名称要与子一级的GridView名称相同,我试过不同也可以,比如这里写Level2也没问题)) //第二个参数是主表的对应键 //第三个参数是子表的对应键 ds.Relations.Add("Level1",ds.Tables[TableField.T_FORM.T_NAME].Columns["FORMID"],ds.Tables[TableField.T_FORM_QUESTION.T_NAME].Columns["FORMID"]); this.gridControl1.DataSource = ds.Tables[0]; }
运行就可以了。
P.S.1:ChildGridViewName的属性我没设置。也没问题。
P.S.2:
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************System.NullReferenceException: Object reference not set to an instance of an object.
这个错误惭愧了,没有把DataSet ds初始化就Add。
P.S.3:
See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.************** Exception Text **************System.ArgumentException: This constraint cannot be enabled as not all values have corresponding parent values.
这个错误是数据问题,这个嵌套表格对于数据要求是“只许父无子,不能子无父”,如果子表的映射键值,在父表中没有,则报此错误。
0 0
- 【新手】DevExpess的GridView嵌套表格
- DEV GRIDVIEW 表格内嵌套表格
- gridview嵌套gridview的方法
- html 表格的嵌套
- GridView的表格用途
- GridView的表格用途
- ScrollView嵌套GridView,GridView的写法
- ScrollView嵌套GridView的解决办法
- ScrollView嵌套GridView的解决办法
- ScrollView嵌套GridView的解决办法
- 简单的GridView嵌套实现
- 简单的GridView嵌套实现
- ScrollView嵌套GridView的解决办法
- ScrollView嵌套GridView的情况
- Viewpager嵌套GridView的实现
- ScrollView嵌套GridView的解决办法
- ScrollView嵌套GridView的解决办法
- ScrollView嵌套GridView的解决办法
- 查询oracle sql的执行计划时,一个很重要的视图--dba_hist_sql_plan
- Linux下玩转Dota2
- H264(NAL简介与I帧判断)
- hdu 1829 A bug’s life
- POJ1149_PIGS(网络流/EK)
- 【新手】DevExpess的GridView嵌套表格
- POJ 2502 Subway(Floyd单源最短路)
- 用poi框架进行批量导入导出实例
- PPTP、L2TP、IPSec和SSL VPN 的区别
- Edit Distance @leetcode
- CentOS x86_64上编译32位demo程序
- Linux字符设备与块设备的区别与比较
- 浙江一副县长辞官 辞职感言:可以长长地舒口气了
- QT 国际化扩展所感 an extending QT Translator (自己实现翻译逻辑,编辑更方便)