hii
I am having a form in which there is one datagridview which is in the flowlayoutpanel and there is other controls such as button an text box at the bottom
I need to resize the datagrid view when the form is resized.but it shud not fill the entire form because the button and text box should not be get affected.but i need the datagrid to fill the maximum part of the screen leaving space for text box and button at the bottom..help me plz...
I think you don't need the FlowLayoutPanel for this purpose. Just try this code in your Designer.cs and tell me if this looks the way you like.
private void InitializeComponent()
{
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.panel1 = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.Size = new System.Drawing.Size(520, 406);
this.dataGridView1.TabIndex = 0;
//
// panel1
//
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.textBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 376);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(520, 30);
this.panel1.TabIndex = 1;
//
// textBox1
//
this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBox1.Location = new System.Drawing.Point(3, 5);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(433, 20);
this.textBox1.TabIndex = 0;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.button1.Location = new System.Drawing.Point(442, 4);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// FormMain
//
this.ClientSize = new System.Drawing.Size(520, 406);
this.Controls.Add(this.panel1);
this.Controls.Add(this.dataGridView1);
this.Name = "FormMain";
this.Text = "FormMain";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
Related
Just for testing I have created a new windows forms project with a picturebox on the form and changed the size of it to 100x100. This is the InitializeComponents function:
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(13, 13);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(100, 100);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
This is my From1_Load function:
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show(pictureBox1.Size.ToString());
}
And this is what I get when I run the app:
Why do I get width=67 height= 65 when it is clear in init that it was meant to be 100x100?
My monitor res is 3840x2160 with change of size of text as 125% Tweaking these settings do not change the result.
Add an image reference.
pictureBox1.Image = Properties.Resources.myImage;
See what happens then, I just need more information to help...
I have form in WinForms that looks like
this
I want the user to be able to resize the form. Buttons would stay the same size and datagridviews would grow when he does this.
Right now, datagridviews are colliding with buttons and It looks pretty ugly.
I want datagridviews to grow, but not collide with buttons.
I've tried many different combinations of code and It doesn't work like I wanted.
I want buttons to be between datagridviews.
Designer:
//
// dataGridView1
//
this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Location = new System.Drawing.Point(13, 60);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 24;
this.dataGridView1.Size = new System.Drawing.Size(291, 326);
this.dataGridView1.TabIndex = 0;
//
// dataGridView2
//
this.dataGridView2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Location = new System.Drawing.Point(566, 60);
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.RowTemplate.Height = 24;
this.dataGridView2.Size = new System.Drawing.Size(284, 326);
this.dataGridView2.TabIndex = 1;
//
// button1
//
this.button1.Anchor = System.Windows.Forms.AnchorStyles.None;
this.button1.Location = new System.Drawing.Point(375, 93);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(121, 83);
this.button1.TabIndex = 2;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// button2
//
this.button2.Anchor = System.Windows.Forms.AnchorStyles.None;
this.button2.Location = new System.Drawing.Point(375, 187);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(121, 83);
this.button2.TabIndex = 3;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// button3
//
this.button3.Anchor = System.Windows.Forms.AnchorStyles.None;
this.button3.Location = new System.Drawing.Point(375, 281);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(121, 83);
this.button3.TabIndex = 4;
this.button3.Text = "button3";
this.button3.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(862, 398);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView2);
this.Controls.Add(this.dataGridView1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
this.ResumeLayout(false);
Try a TableLayoutPanel. You can define 3 columns, the first one set to 50%, the second one to the width of your buttons (or set to AutoSize, initially set it to an absolute or percentage value, then place your buttons. One placed go back and change to autosize otherwise the column will shrink to nothing if there's nothing in the column) and the third to 50%. Then you'll need at least 3 rows, 1 row per button.
Put your first DataGridView in Cell 0,0 (Col 0, Row 0) and set RowSpan to 3. Put your second DataGridView in Cell 2,0 (Col 2, Row 0) and, again, set RowSpan to 3. Then in the middle column (col 1) put your 3 buttons, one in each row. You can remove anchoring at that point so the buttons float in the middle of the column. Set your datagridviews to DockStyle.Fill and you shouldn't have any issues with the DataGridRow overlapping the buttons.
Here's a couple of screenshots.
Use the Anchor Property to your Datagridview and buttons.
I'm trying to build "dashboard" like layout for my WinForms application.
I was able to build simple concept using TableLayoutPanel.
I'm able to add columns, rows and controls to tlp (TableLayoutPanel), but I get unwanted behaviour:
I have padding set to 5 on tlp, but after adding two rows that padding disappears - I can scroll to bottom, but I'd like that padding to be visible when scrollbar is at bottom.
I'm adding new row with this code:
private void newButton_Click(object sender, EventArgs e)
{
var x = tableLayoutPanel1.RowStyles.Count - 1;
tableLayoutPanel1.RowStyles.Insert(x,new RowStyle(SizeType.Absolute,100));
var b = new Button
{
Dock = DockStyle.Fill,
Text = "New"+x.ToString(),
UseVisualStyleBackColor = true
};
tableLayoutPanel1.RowCount++;
x = tableLayoutPanel1.RowStyles.Count - 2;
tableLayoutPanel1.Controls.Add(b,0,x);
}
Is this behaviour by design or can I change it? Basically I'd like that bottom padding to be visible when I scroll to bottom on tlp.
As requested this is my tlp design code:
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.AutoScroll = true;
this.tableLayoutPanel1.AutoScrollMargin = new System.Drawing.Size(10, 10);
this.tableLayoutPanel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.tableLayoutPanel1.Controls.Add(this.button1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.button2, 1, 0);
this.tableLayoutPanel1.Cursor = System.Windows.Forms.Cursors.Default;
this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(459, 221);
this.tableLayoutPanel1.TabIndex = 0;
//
// button1 - button in top left cell in tlp
//
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
this.button1.Location = new System.Drawing.Point(8, 8);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(218, 94);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
//
// button2 - button in top right cell in tlp
//
this.button2.Dock = System.Windows.Forms.DockStyle.Fill;
this.button2.Location = new System.Drawing.Point(232, 8);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(219, 94);
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
//
// button5 - "Test" button
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button5.Location = new System.Drawing.Point(12, 427);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 1;
this.button5.Text = "Test";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(755, 462);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.button5);
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.tableLayoutPanel1.ResumeLayout(false);
this.ResumeLayout(false);
}
At first I have 2 rows, first set to 100 pixels absolute size, second to autofill, when I click "Test" button I'm inserting row that has same properties as first (absolute size, 100 px height)
Thanks to #Sinatr and #TaW I've solved my problem.
As You may see after adding more rows and scrolling to bottom padding is still visible (desirable effect).
The key was to put TableLayoutPanel inside UserControl.
Here are properties that must be set:
TableLayoutPanel (inside UserControl):
Dock:Top
AutoSize:True
AutoScroll:False
UserControl:
AutoScroll:True
Below is designer code from my UserControl:
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.AutoSize = true;
this.tableLayoutPanel1.BackColor = System.Drawing.SystemColors.ActiveCaption;
this.tableLayoutPanel1.ColumnCount = 3;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.34F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
this.tableLayoutPanel1.Cursor = System.Windows.Forms.Cursors.Default;
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Top;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.Padding = new System.Windows.Forms.Padding(5);
this.tableLayoutPanel1.RowCount = 1;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(443, 10);
this.tableLayoutPanel1.TabIndex = 1;
//
// Dashboard
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "Dashboard";
this.Size = new System.Drawing.Size(443, 208);
this.Load += new System.EventHandler(this.Dashboard_Load);
this.MouseEnter += new System.EventHandler(this.Dashboard_MouseEnter);
this.ResumeLayout(false);
this.PerformLayout();
}
I hope this help anyone having same problem.
I've been messing around with something that should be simple.
I've moved jobs and trying to get some of the basic tools I have used before, but of course I don't have the old source to look at.
We had extended panel to have some standard properties and functions (save, close, save and close).
But I can't get the buttons to be positioned correctly on a resize. I put this ExtPanel on a form but the buttons keep disappearing as I resize, or don't move as expected (frozen on bottom right).
The class
public partial class ExtPanel: UserControl
{
private System.Windows.Forms.Button btnSaveandClose;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnSave;
public ExtPanel ()
{
InitializeComponent ();
}
// misc things this class does...
}
public partial class ExtPanel
{
private void InitializeComponent ()
{
this.btnSaveandClose = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// btnSaveandClose
//
this.btnSaveandClose.Location = new System.Drawing.Point(899, 689);
this.btnSaveandClose.Name = "btnSaveandClose";
this.btnSaveandClose.Size = new System.Drawing.Size(100, 30);
this.btnSaveandClose.TabIndex = 0;
this.btnSaveandClose.Text = "Save and Close";
this.btnSaveandClose.UseVisualStyleBackColor = true;
this.btnSaveandClose.Click += new System.EventHandler(this.Click_SaveandClose);
this.btnSaveandClose.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(687, 689);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(100, 30);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.Click_Close);
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(793, 689);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(100, 30);
this.btnSave.TabIndex = 2;
this.btnSave.Text = "Save";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.Click_Save);
this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.Controls.Add(this.btnSave);
this.panel1.Controls.Add(this.btnCancel);
this.panel1.Controls.Add(this.btnSaveandClose);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(1008, 730);
this.panel1.TabIndex = 0;
//
// ExtPanel
//
this.Controls.Add(this.panel1);
this.Name = "ExtPanel";
this.Size = this.panel1.Size;
this.Click += new System.EventHandler(this.click_this);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
}
Have you tried anchoring the button?
...I missed the anchoring code.
If you have a button in the lower right-hand corner that you want to stay in the lower right-hand corner when resizing the form, set it's anchor properties to Bottom, Right.
Update:
I loaded your code. You have a panel inside of ExtPanel. If you dock (Fill) that panel then you should be working fine by resizing ExtPanel.
I'm not 100% sure how I should word this question but I'll try my best.
I have a PointCtrlForm that has a DataGridView inside a TableLayoutPanel. The DataGridView is docked to the table as Fill. PointCtrlForm is docked to another window set as MDIParent with the dockstyle property set as Fill.
Resizing the main window properly resizes the PointCtrlForm, which then is supposed to resize the DataGridView as well. Well, at least "half" of the resizing works properly. Enlarging the main window also enlarges the datagridview, which is what I expected but if I shrink the main window to a certain point, the DataGridView stops shrinking and hides the columns without showing a scrollbar.
I've checked that all columns do not have Frozen property enabled, checked that both the datagridview and the child window is properly docked, and checked the scrollbars property is set to both.
Edit: AutoSizeColumnsMode is also fill.
I'll post the content of the Designer.cs here. I'd appreciate any guidance.
namespace DDCUI
{
partial class PointCtrlForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.CmbSubDevice = new System.Windows.Forms.ComboBox();
this.BtnBack = new System.Windows.Forms.Button();
this.CmbMainDevice = new System.Windows.Forms.ComboBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.BtnRefresh = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PointName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Value = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Description = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DefaultValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ActiveString = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.InactiveString = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.AlarmCondition = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.tableLayoutPanel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 6;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 151F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 88F));
this.tableLayoutPanel1.Controls.Add(this.CmbSubDevice, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.BtnBack, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.CmbMainDevice, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.dataGridView1, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.BtnRefresh, 4, 1);
this.tableLayoutPanel1.Controls.Add(this.label1, 5, 1);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 67.02128F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 32.97872F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 368F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(639, 467);
this.tableLayoutPanel1.TabIndex = 0;
//
// CmbSubDevice
//
this.tableLayoutPanel1.SetColumnSpan(this.CmbSubDevice, 2);
this.CmbSubDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CmbSubDevice.Font = new System.Drawing.Font("굴림", 12F);
this.CmbSubDevice.FormattingEnabled = true;
this.CmbSubDevice.Location = new System.Drawing.Point(203, 69);
this.CmbSubDevice.Name = "CmbSubDevice";
this.CmbSubDevice.Size = new System.Drawing.Size(194, 24);
this.CmbSubDevice.TabIndex = 3;
//
// BtnBack
//
this.BtnBack.Location = new System.Drawing.Point(3, 3);
this.BtnBack.Name = "BtnBack";
this.BtnBack.Size = new System.Drawing.Size(94, 54);
this.BtnBack.TabIndex = 0;
this.BtnBack.Text = "Back";
this.BtnBack.UseVisualStyleBackColor = true;
this.BtnBack.Click += new System.EventHandler(this.BtnBack_Click);
//
// CmbMainDevice
//
this.tableLayoutPanel1.SetColumnSpan(this.CmbMainDevice, 2);
this.CmbMainDevice.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.CmbMainDevice.Font = new System.Drawing.Font("굴림", 12F);
this.CmbMainDevice.FormattingEnabled = true;
this.CmbMainDevice.Items.AddRange(new object[] {
"I/O",
"VIRTUAL",
"SAC",
"MODBUS",
"NATIONAL",
"TOSHIBA",
"SCHEDULE",
"SYSTEM ALARM",
"LOGIC",
"GROUP"});
this.CmbMainDevice.Location = new System.Drawing.Point(3, 69);
this.CmbMainDevice.Name = "CmbMainDevice";
this.CmbMainDevice.Size = new System.Drawing.Size(194, 24);
this.CmbMainDevice.TabIndex = 2;
this.CmbMainDevice.SelectedIndexChanged += new System.EventHandler(this.CmbMainDevice_SelectedIndexChanged);
//
// dataGridView1
//
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.PointName,
this.Value,
this.Description,
this.DefaultValue,
this.ActiveString,
this.InactiveString,
this.AlarmCondition});
this.tableLayoutPanel1.SetColumnSpan(this.dataGridView1, 6);
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(3, 101);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(633, 363);
this.dataGridView1.TabIndex = 5;
//
// BtnRefresh
//
this.BtnRefresh.Location = new System.Drawing.Point(403, 69);
this.BtnRefresh.Name = "BtnRefresh";
this.BtnRefresh.Size = new System.Drawing.Size(94, 26);
this.BtnRefresh.TabIndex = 6;
this.BtnRefresh.Text = "Refresh";
this.BtnRefresh.UseVisualStyleBackColor = true;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Font = new System.Drawing.Font("굴림", 12F);
this.label1.Location = new System.Drawing.Point(554, 66);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(82, 32);
this.label1.TabIndex = 7;
this.label1.Text = "XXX 개";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// ID
//
this.ID.FillWeight = 70F;
this.ID.HeaderText = "ID";
this.ID.Name = "ID";
//
// PointName
//
this.PointName.FillWeight = 70F;
this.PointName.HeaderText = "이름";
this.PointName.Name = "PointName";
//
// Value
//
this.Value.FillWeight = 70F;
this.Value.HeaderText = "값";
this.Value.Name = "Value";
//
// Description
//
this.Description.FillWeight = 70F;
this.Description.HeaderText = "설명";
this.Description.Name = "Description";
//
// DefaultValue
//
this.DefaultValue.FillWeight = 70F;
this.DefaultValue.HeaderText = "초기값";
this.DefaultValue.Name = "DefaultValue";
//
// ActiveString
//
this.ActiveString.HeaderText = "Active문자열";
this.ActiveString.Name = "ActiveString";
//
// InactiveString
//
this.InactiveString.HeaderText = "InActive문자열";
this.InactiveString.Name = "InactiveString";
//
// AlarmCondition
//
this.AlarmCondition.HeaderText = "알람조건";
this.AlarmCondition.Name = "AlarmCondition";
//
// PointCtrlForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(639, 467);
this.Controls.Add(this.tableLayoutPanel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "PointCtrlForm";
this.Text = "LG-DDC";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Button BtnBack;
private System.Windows.Forms.ComboBox CmbMainDevice;
private System.Windows.Forms.ComboBox CmbSubDevice;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button BtnRefresh;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
private System.Windows.Forms.DataGridViewTextBoxColumn PointName;
private System.Windows.Forms.DataGridViewTextBoxColumn Value;
private System.Windows.Forms.DataGridViewTextBoxColumn Description;
private System.Windows.Forms.DataGridViewTextBoxColumn DefaultValue;
private System.Windows.Forms.DataGridViewTextBoxColumn ActiveString;
private System.Windows.Forms.DataGridViewTextBoxColumn InactiveString;
private System.Windows.Forms.DataGridViewTextBoxColumn AlarmCondition;
}
}
I've found the solution and it's rather simple.
The row and column sizes for the DGV has to be set "percentage (relative)" not "absolute" in order for the docking to work properly.
You can edit the sizes by right clicking on one of the cells of the DGV and clicking on Edit Row/Column Properties.