WinForm中DataGridView折叠控件【超好看】(2)

public class detailControl : Ewin.Client.Frame.Controls.EwinPanel { #region 字段 public List<DataGridView> childGrid = new List<DataGridView>(); public DataSet _cDataset; #endregion #region 方法 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; cModule.applyGridTheme(newGrid); cModule.setGridRowHeader(newGrid); newGrid.RowPostPaint += cModule.rowPostPaint_HeaderCount; childGrid.Add(newGrid); } public void Add(string tableName) { //TabPage tPage = new TabPage() { Text = pageCaption }; //this.Controls.Add(tPage); DataGridView newGrid = new Ewin.Client.Frame.Controls.EwinGrid() { Dock = DockStyle.Fill, DataSource = new DataView(_cDataset.Tables[tableName]) }; newGrid.AllowUserToAddRows = false; //tPage.Controls.Add(newGrid); this.Controls.Add(newGrid); cModule.applyGridTheme(newGrid); cModule.setGridRowHeader(newGrid); newGrid.RowPostPaint += cModule.rowPostPaint_HeaderCount; childGrid.Add(newGrid); } public void RemoveControl() { this.Controls.Remove(childGrid[]); childGrid.Clear(); } #endregion }

3、cModule.cs用来设置样式

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjwwwj.html