locked
How to prevent DataGridView with Dock = Fill from overlapping other controls... RRS feed

  • Question

  • I have a form with several labels across the top of it, and a DataGridView below the labels.

    I need the DGV to fill the entire form, but not to overlap the labels at the top of the form. When the form is resized, I want the DGV to remain the same size, but for the appropriate scroll bars to appear on the form.

    When I set DGV.Dock to Fill, I get exactly the behaviour I want, except that the DGV fills the entire form, and the top part of the DBV overlaps  (actually "underlaps") the labels.

    Basically, I need to "reserve" space for the labels at the top of the form, and have the DGV fill the rest of the form.  But how?  Do I need to Dock the DGV inside another control, like Panel?

    Thanks,

     

      

     

    Friday, October 22, 2010 3:58 PM

Answers

  • You can add a panel in which you can add all the controls like labels, textboxes, etc. except datagridview. Then you can set Dock property of Panel as Top and Dock property of Datagridview as Fill. That should solve your problem.
    Gaurav Khanna
    Friday, October 22, 2010 6:10 PM

All replies