调整大小在FlowLayoutPanel的

问题描述:

HII 我有一个形式,其中有一个的datagridview这是在FlowLayoutPanel的和有其他控件,例如底部按钮调整大小在FlowLayoutPanel的

一个文本框我需要调整数据网格视图当表单被调整大小时,但它不会填满整个表单,因为按钮和文本框不应该受到影响。但我需要datagrid填充屏幕的最大部分,为文本框和底部留下空间。 .help me plz ...

我觉得你不需要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; 
+0

非常感谢...... – amk 2010-10-01 12:20:12