zoukankan      html  css  js  c++  java
  • 级联datagridview 利用datarelation和bindingsource

       // TODO: 这行代码将数据加载到表“dataSet2.Son”中。您可以根据需要移动或移除它。
                this.sonTableAdapter.Fill(this.dataSet2.Son);
                // TODO: 这行代码将数据加载到表“dataSet2.Parent”中。您可以根据需要移动或移除它。
                this.parentTableAdapter.Fill(this.dataSet2.Parent);
             

    以下完全可以可视化操作完成.
                //DataColumn parentCol = dbSet.Tables["Customers"].Columns["CustomerID"];
                //DataColumn childCol = dbSet.Tables["Orders"].Columns["CustomerID"];
                //DataRelation relation = new DataRelation("FK_Customers_Orders", parentCol, childCol);  // 建立主从关系       
                //dbSet.Relations.Add(relation);  // 添加主从关系到数据集中      
      
                //BindingSource bs_Customers = new BindingSource();  // 创建绑定源    
                //BindingSource bs_Orders = new BindingSource();         
                //bs_Customers.DataSource = dbSet;        
                //bs_Customers.DataMember = "Customers";  // 绑定到数据源——主表       

                //bs_Orders.DataSource = bs_Customers;        //绑定到上一BindingSource
                //bs_Orders.DataMember = "FK_Customers_Orders";  // 绑定到关系——从表,注意:区分大小写     

                //dataGridView1.DataSource = bs_Customers;  // DataGridView 显示       
                //dataGridView2.DataSource = bs_Orders;

  • 相关阅读:
    使用Junit对Spring进行单元测试实战小结
    【VBA编程】02.调试VBA程序
    【VBA编程】01.第一个VBA程序Hello world
    VBA验证工作表是否存在
    VBA对指定单元格填充颜色并且赋值
    Excle中range的一些用法
    Debug.print的用法
    EXCLE图形插入实例
    DB2建立不记录日志的表
    Excle快速输入√与×
  • 原文地址:https://www.cnblogs.com/wucg/p/1755632.html
Copyright © 2011-2022 走看看