private void createMasterDetailView() { masterDetail = new MasterControl(northwindDataSet1); panelView.Controls.Add(masterDetail); masterDetail.setParentSource(northwindDataSet1.BankRS.TableName, "Firms"); masterDetail.childView.Add(northwindDataSet1.KeyFirms.TableName, "Фирмы"); masterDetail.childView.Add(northwindDataSet1.Person.TableName, "Директоры"); }
public void MasterControl_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) //Handles MyBase.RowPostPaint { //set childview control Rectangle rect = new Rectangle(e.RowBounds.X + ((rowDefaultHeight - 16) / 2), e.RowBounds.Y + ((rowDefaultHeight - 16) / 2), 16, 16); MasterControl send = (MasterControl)sender; if (collapseRow) { if (rowCurrent != null && rowCurrent.Contains(e.RowIndex)) { // MyBase.RowPostPaint send.Rows[e.RowIndex].DividerHeight = send.Rows[e.RowIndex].Height - rowDefaultHeight; // e.Graphics.DrawImage(RowHeaderIconList.Images[rowHeaderIcons.collapse], rect); e.Graphics.DrawImage(RowHeaderIconList.Images[0], rect); childView.Location = new Point(e.RowBounds.Left + send.RowHeadersWidth, e.RowBounds.Top + rowDefaultHeight + 5); childView.Width = e.RowBounds.Right - send.RowHeadersWidth; childView.Height = send.Rows[e.RowIndex].DividerHeight - 10; childView.Visible = true; } else { childView.Visible = false; // e.Graphics.DrawImage(RowHeaderIconList.Images[rowHeaderIcons.expand], rect); e.Graphics.DrawImage(RowHeaderIconList.Images[1], rect); } collapseRow = false; } else if (rowCurrent != null && rowCurrent.Contains(e.RowIndex)) { send.Rows[e.RowIndex].DividerHeight = send.Rows[e.RowIndex].Height - rowDefaultHeight; // e.Graphics.DrawImage(RowHeaderIconList.Images[rowHeaderIcons.collapse], rect); e.Graphics.DrawImage(RowHeaderIconList.Images[0], rect); childView.Location = new Point(e.RowBounds.Left + send.RowHeadersWidth, e.RowBounds.Top + rowDefaultHeight + 5); childView.Width = e.RowBounds.Right - send.RowHeadersWidth; childView.Height = send.Rows[e.RowIndex].DividerHeight - 10; childView.Visible = true; } // else e.Graphics.DrawImage(RowHeaderIconList.Images[rowHeaderIcons.expand], rect); else { e.Graphics.DrawImage(RowHeaderIconList.Images[1], rect); } // rowPostPaint_HeaderCount(sender, e); }
private void clearFields() { panelView.Controls.Clear(); masterDetail = null; Refresh(); }