public void SetControl(MasterControl oGrid) { oGrid.ChildView.RemoveControl(); //oGrid.childView.Controls.RemoveByKey("ChildrenMaster"); // //var oRelates = _cDataset.Relations[1]; //oGrid.childView.Add(oRelates.ParentTable.TableName, oRelates.ChildColumns[0].ColumnName); //foreach (var oGridControl in oGrid.Controls) //{ // if (oGridControl.GetType() != typeof(detailControl)) // { // continue; // } // var DetailControl =(detailControl)oGridControl; // foreach (var odetailControl in DetailControl.Controls) // { // if (odetailControl.GetType() != typeof(MasterControl)) // { // continue; // } // var OMasterControl = (MasterControl)odetailControl; // foreach (var oMasterControl in OMasterControl.Controls) // { // if (oMasterControl.GetType() == typeof(detailControl)) // { // ((detailControl)oMasterControl).Visible = false; // return; // } // } // } //} }
public void Add(string tableName, string strPrimaryKey, string strForeignKey) { //TabPage tPage = new TabPage() { Text = pageCaption }; //this.Controls.Add(tPage); MasterControl newGrid = new MasterControl(CDataset, ControlType.Middle) { Dock = DockStyle.Fill, DataSource = new DataView(CDataset.Tables[tableName]) }; newGrid.SetParentSource(tableName, strPrimaryKey, strForeignKey);//设置主外键 //newGrid.Name = "ChildrenMaster"; //tPage.Controls.Add(newGrid); this.Controls.Add(newGrid); //this.BorderStyle = BorderStyle.FixedSingle; CModule.ApplyGridTheme(newGrid); CModule.SetGridRowHeader(newGrid); newGrid.RowPostPaint += CModule.rowPostPaint_HeaderCount; ChildGrid.Add(newGrid); }