b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

datagridview重叠_datagridview绑定list_datagridview右键菜单(62)

电脑杂谈  发布时间:2017-05-30 08:07:57  来源:网络整理

// key (orderID) already exists.

if (!checkState.ContainsKey(orderID))

{

checkState.Add(orderID, (bool)e.Value);

}

else

checkState[orderID] = (bool)e.Value;

}

}

21. How do I show data that comes from two tables(TODO)?

The DataGridView does not provide any new features apart from virtual mode to enable this. What you can do is use the JoinView class described in the following article?scid=kb;en-us;325682. Using this class you can join two or more DataTables together. This JoinView can then be databound to the DataGridView.

22. 如何显示主从表?

使用DataGridView时最常见的情况之一就是主从表单,这时要显示具有主从关系的两个数据表。在主表中选择一行记录,从表中也会随之变化,显示相应的记录。

通过DataGridView控件和BindingSource 组件的交互作用来实现主从表单是非常简单的。下面的示例演示的是SQL Server的范例Northwind 中的两个表:Customers 和Orders。在主DataGridView中选择一个顾客,那么该顾客的所有订单会显示在从DataGridView 中。

using System;

using System.Data;

using System.Data.SqlClient;

using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form

{

private DataGridView masterDataGridView = new DataGridView();

private BindingSource masterBindingSource = new BindingSource();

private DataGridView detaiataGridView = new DataGridView();

private BindingSource detailsBindingSource = new BindingSource();

[STAThreadAttribute()]

public static void Main()

{

Application.Run(new Form1());

}

// Initializes the form.

public Form1()

{

masterDataGridView.Dock = DockStyle.Fill;

detaiataGridView.Dock = DockStyle.Fill;

SplitContainer splitContainer1 = new SplitContainer();

splitContainer1.Dock = DockStyle.Fill;

splitContainer1.Orientation = Orientation.Horizontal;


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-50070-62.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...