datagridview problem in tablelayout panel
-
Friday, September 21, 2012 11:20 AM
Hi I have a table layout panel and in that i have kept datagridview and picturebox.this.tlpFreeNumbers.ColumnCount = 2; this.tlpFreeNumbers.AutoSize = true; this.tlpFreeNumbers.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.tlpFreeNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tlpFreeNumbers.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25F)); this.tlpFreeNumbers.Controls.Add(this.dgvfreeNumbers, 0, 0); this.tlpFreeNumbers.Controls.Add(this.pcbGridError, 1, 0); this.tlpFreeNumbers.Dock = System.Windows.Forms.DockStyle.Fill; this.tlpFreeNumbers.Location = new System.Drawing.Point(4, 19); this.tlpFreeNumbers.Name = "tlpFreeNumbers"; this.tlpFreeNumbers.RowCount = 1; this.tlpFreeNumbers.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tlpFreeNumbers.Size = new System.Drawing.Size(800, 157); this.tlpFreeNumbers.TabIndex = 0;
this.dgvfreeNumbers.AllowUserToAddRows = false; this.dgvfreeNumbers.AllowUserToDeleteRows = false; this.dgvfreeNumbers.AllowUserToResizeRows = false; dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(227)))), ((int)(((byte)(227)))), ((int)(((byte)(227))))); this.dgvfreeNumbers.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dgvfreeNumbers.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; this.dgvfreeNumbers.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvfreeNumbers.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvfreeNumbers.Location = new System.Drawing.Point(3, 3); this.dgvfreeNumbers.Margin = new System.Windows.Forms.Padding(6, 0, 0, 6); this.dgvfreeNumbers.MultiSelect = false; this.dgvfreeNumbers.Name = "dgvfreeNumbers"; this.dgvfreeNumbers.RowHeadersVisible = false; this.dgvfreeNumbers.RowTemplate.Height = 24; this.dgvfreeNumbers.Size = new System.Drawing.Size(800, 151); this.dgvfreeNumbers.TabIndex = 0;this.pcbGridError.Location = new System.Drawing.Point(100, 3); this.pcbGridError.Name = "pcbGridError"; this.pcbGridError.Size = new System.Drawing.Size(37, 32); this.pcbGridError.TabIndex = 1; this.pcbGridError.TabStop = false;I have declared as above in the designer my problem is When error occurs picture box should be displayed or else
Picture box should not be displayed. When i load the below scrren is displayed in that if we observe there is
Gap between groupbox and grid. I need to remove the gap when loaded the Grid should be filled fully. And when error comes
Picture box should be displayed by slightly shrinking the Grid. Is is possible could you let me know.
All Replies
-
Monday, September 24, 2012 7:16 AMModerator
Hi Raju_Hai,
Base on my understanding. If you set the Dock property of the DataGridView to None at design time, you can direcly set the Dock property to Fill / None so that the dataGridView will fill fully or the original size.
dataGridView1.Dock = DockStyle.Fill;
Best regards,Chester Hong
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Thursday, September 27, 2012 8:29 AMModerator
Hi Raju_Hai,
How is everything going now?
Does it work to set to Dock property?
Best regards,
Chester Hong
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
Thursday, September 27, 2012 9:40 AM
Hi Chester,
Sorry for the late reply. It is not working when doc property is set at runtime also. Working on that how to make the
grid fill the space.


