續:datagrid主從表如何分別在兩個datagrid顯示(BindingManagerBase)
derek 2003-08-19 02:59:36 參照:http://www.csdn.net/develop/Read_Article.asp?Id=17840 建立主從時出現問題:
//建立customers和聯繫人的relation
DataRelation datarelation;
DataColumn datacolumn1;
DataColumn datacolumn2;
datacolumn1=this.ds.Tables["customers"].Columns["custid"];
datacolumn2=this.ds.Tables["contacts"].Columns["custid"];
datarelation=new DataRelation("CustomerToContacts",datacolumn1,datacolumn2);
BindingManagerBase bmbaseParent = this.BindingContext[this.ds ,"customers"];
BindingManagerBase bmbaseChild =this.BindingContext[this.ds,"customers.datarelation"]; // 出現錯誤提示
錯誤提示內容:
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot create a child list for field datarelation.