HII 我有一个表单,其中有一个datagridview在flowlayoutpanel中,还有其他控件,如按钮和底部的文本框
我需要在调整窗体大小时调整datagrid视图的大小。但是它不会填满整个窗体,因为按钮和文本框不应该受到影响。但是我需要datagrid来填充屏幕的最大部分离开文本框的空间和底部的按钮。帮助我PLZ ...
答案 0 :(得分:3)
我认为您不需要FlowLayoutPanel
来达到此目的。只需在Designer.cs中尝试此代码,并告诉我这是否符合您的喜好。
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;