Esempio n. 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])
            };

            newGrid.AllowUserToAddRows = false;
            //tPage.Controls.Add(newGrid);
            this.Controls.Add(newGrid);
            CellStyle.applyGridTheme(newGrid);
            CellStyle.setGridRowHeader(newGrid);
            newGrid.RowPostPaint += CellStyle.rowPostPaint_HeaderCount;
            childGrid.Add(newGrid);
        }
Esempio n. 2
0
 /// <summary>
 /// 设置表之间的主外键关联
 /// </summary>
 /// <param name="tableName">DataTable的表名称</param>
 /// <param name="foreignKey">外键</param>
 public void setParentSource(string tableName, string primarykey, string foreignKey)
 {
     this.DataSource = new DataView(_cDataset.Tables[tableName]);
     CellStyle.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(decimal).ToString())
     {
         _filterFormat = foreignKey + "={0}";
     }
     else
     {
         _filterFormat = foreignKey + "=\'{0}\'";
     }
 }
Esempio n. 3
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);
        }