views:

10

answers:

1

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...

+1  A: 

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;
Oliver
great thanks alot ......
amk