Пример #1
0
        public void Add2(string tableName)
        {
            //TabPage tPage = new TabPage() { Text = pageCaption };
            //this.Controls.Add(tPage);
            DataGridView newGrid = new DataGridView
            {
                Dock               = DockStyle.Fill,
                DataSource         = new DataView(CDataset.Tables[tableName]),
                AllowUserToAddRows = false
            };

            //tPage.Controls.Add(newGrid);
            this.Controls.Add(newGrid);
            CModule.ApplyGridTheme(newGrid);
            CModule.SetGridRowHeader(newGrid);
            newGrid.RowPostPaint += CModule.rowPostPaint_HeaderCount;
            ChildGrid.Add(newGrid);
        }
Пример #2
0
 /// <summary>
 /// 设置表之间的主外键关联
 /// </summary>
 /// <param name="tableName">DataTable的表名称</param>
 /// <param name="primarykey"></param>
 /// <param name="foreignKey">外键</param>
 public void SetParentSource(string tableName, string primarykey, string foreignKey)
 {
     this.DataSource = new DataView(_cDataset.Tables[tableName]);
     CModule.SetGridRowHeader(this);
     _foreignKey = foreignKey;
     _primaryKey = primarykey;
     if (_cDataset.Tables[tableName].Columns[primarykey].GetType().ToString() == typeof(int).ToString() ||
         _cDataset.Tables[tableName].Columns[primarykey].GetType().ToString() == typeof(double).ToString() ||
         _cDataset.Tables[tableName].Columns[primarykey].GetType().ToString() == typeof(long).ToString() ||
         _cDataset.Tables[tableName].Columns[primarykey].GetType().ToString() == typeof(decimal).ToString())
     {
         _filterFormat = foreignKey + "={0}";
     }
     else
     {
         _filterFormat = foreignKey + "=\'{0}\'";
     }
 }
Пример #3
0
        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);
        }