private void tsbSelect_Click(object sender, EventArgs e) { if (tsbExit.Visible) { return; } if (tsbExitPrint.Visible) { tsbExitPrint_Click(null, null); } gbxUp.Visible = false; dgvInfo.Visible = false; tsbExit.Visible = true; ucInfo frm = new ucInfo(); gbxMiddle.Controls.Add(frm); frm.Dock = DockStyle.Fill; frm.tableLayoutPanel.RowCount = this.dgvInfo.ColumnCount; for (int i = 0; i < this.dgvInfo.ColumnCount - 1; i++) { Label lblName = new Label(); lblName.Text = this.dgvInfo.Columns[i].Name; frm.tableLayoutPanel.Controls.Add(lblName); Label lblValue = new Label(); lblValue.Text = this.dgvInfo[i, 0].Value.ToString(); lblValue.Anchor = AnchorStyles.Left; frm.tableLayoutPanel.Controls.Add(lblValue); lblValue.DataBindings.Add("Text", this.dgvInfo.DataSource, lblName.Text); } }
private void tsbSelect_Click(object sender, EventArgs e) { if (tsbExit.Visible) { return; } if (tsbExitPrint.Visible) { tsbExitPrint_Click(null, null); } gbxUp.Visible = false; dgvInfo.Visible = false; tsbExit.Visible = true; ucInfo frm = new ucInfo(); gbxMiddle.Controls.Add(frm); frm.Dock = DockStyle.Fill; frm.tableLayoutPanel.RowCount = this.dgvInfo.ColumnCount; for (int i = 0; i < this.dgvInfo.ColumnCount - 1; i++) { Label lblName = new Label(); lblName.Text = this.dgvInfo.Columns[i].Name; frm.tableLayoutPanel.Controls.Add(lblName); Label lblValue = new Label(); lblValue.Text = this.dgvInfo[i, 0].Value.ToString(); lblValue.Anchor = AnchorStyles.Left; frm.tableLayoutPanel.Controls.Add(lblValue); lblValue.DataBindings.Add("Text", this.dgvInfo.DataSource,lblName.Text); } }