DataGridView Dock RRS feed

  • Question

  • First, I created a Panel called "Footer" and set the Dock = Bottom and then I created the DataGridView and set the Dock=Fill. Now I want to add another Panel called "Header" and set the Dock=Top. However, when I do that it covers part of the DataGridView.

    Does anyone know how I can fix this?

    Friday, July 9, 2010 3:21 PM


  • Hi DanuGai,

    I guess what you want is the DataGridView fill the middle part between the two panels. If I'm off base, please correct me.

    The cause of the dataGridView will be coverd by panel "Header" is because when you do the drag and drop the DataGridView, it drops inside the panel "Header", that is to say, you will find in Form1.Designer.cs code "this.Header.Controls.Add(this.dataGridView1);", it means the DataGridView belongs to the panel. All you have to do is make the DataGridView belongs directly to the form, not the panel "Header", you can copy it out from panel "Header" to the form, that will lead the Form1.Designer.cs automatically coding "this.Controls.Add(this.dataGridView1);"  

    Helen Zhou


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Helen Zhou Friday, July 16, 2010 7:16 AM
    Wednesday, July 14, 2010 3:19 PM