关于DataGrid编程 1. datagrid.datasourse = yourDataSetName.table[0]; //指定表. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 How can I bind two datagrids in a Master-Detail relationship?http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q780q 问题一:this.sqlDataAdapter1.Fill(this.dataSet1,"Demo");this.dataView1=this.dataSet1..Tables["Demo"].DefaultView;this.dataView1.AllowEdit = false;this.dataView1.AllowDelete = false;this.dataView1.AllowNew = false;this.dataGrid1.DataSource=dataView1;问题二:关于第二个问题,可以定义了个System.Windows.Forms.BindingManagerBase mybind;this.mybind = this.BindingContext[this.dataView1];this.mybind.PositionChanged += new EventHandler(mybind_PositionChanged);然后再定义了个事件:private void mybind_PositionChanged(object sender,System.EventArgs e){.....//这里就是你所想要的,在dataGrid2中进行加载数据!}希望对你有帮助!呵呵…… dataGrid.datasourse = 数据源名; 1、数据源绑定到DataSet而不是DataTable。2、MSDN演练里有一个主从表的完整的例子。 使用两个DataGrid通过DataRelation绑定不同的数据表。设置绑定的DataMember就行了this.dataGrid1.DataSource = this.ds1;this.dataGrid1.DataMember = "table1";this.dataGrid2.DataSource = this.ds1;this.dataGrid2.DataMember = "table1.relation12";relation12是两个表之间的关系名。楼主要定义他们的关系使用DataRelation对象。 类的调用问题 C#不可忍受之慢——谁是罪魁祸首 winform窗口随Panel大小变化而变化问题 加密问题求助 急 求C# 生成界面文件aspx 的代码 求救!!!! 如何编辑一个按钮,点击这个按钮就可以让DataGrid选中下一行呢? 求助,关于wcf的问题 BackgroundWorker的问题(winform异步提取数据,并精确显示进度条) 这样用c#开发asp.net应用程序? 请问Randomize 的应用,希望有一个例子可以说明。 急救.关于引用的问题.
http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp#q780q
this.sqlDataAdapter1.Fill(this.dataSet1,"Demo");
this.dataView1=this.dataSet1..Tables["Demo"].DefaultView;
this.dataView1.AllowEdit = false;
this.dataView1.AllowDelete = false;
this.dataView1.AllowNew = false;
this.dataGrid1.DataSource=dataView1;
问题二:
关于第二个问题,可以定义了个
System.Windows.Forms.BindingManagerBase mybind;
this.mybind = this.BindingContext[this.dataView1];
this.mybind.PositionChanged += new EventHandler(mybind_PositionChanged);
然后再定义了个事件:
private void mybind_PositionChanged(object sender,System.EventArgs e)
{
.....//这里就是你所想要的,在dataGrid2中进行加载数据!
}希望对你有帮助!
呵呵……
设置绑定的DataMember就行了
this.dataGrid1.DataSource = this.ds1;
this.dataGrid1.DataMember = "table1";this.dataGrid2.DataSource = this.ds1;
this.dataGrid2.DataMember = "table1.relation12";relation12是两个表之间的关系名。
楼主要定义他们的关系使用DataRelation对象。