コード例 #1
0
        private 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;
            //            }
            //        }
            //    }
            //}
        }
コード例 #2
0
        public void Add(string tableName, string strPrimaryKey, string strForeignKey)
        {
            //TabPage tPage = new TabPage() { Text = pageCaption };
            //this.Controls.Add(tPage);
            var 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;
            CellStyle.applyGridTheme(newGrid);
            CellStyle.setGridRowHeader(newGrid);
            newGrid.RowPostPaint += CellStyle.rowPostPaint_HeaderCount;
            childGrid.Add(newGrid);
        }