Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Undesirable behavior with control "dock" property
 

Undesirable behavior with control "dock" property

I have a MDI child form that I initially placed a grid and set its doc property to "Fill". I decided to place some buttons on the form, so reset the property to "None" and dragged a panel below it. I set the newPanel doc property to "Bottom" and sized it to hold the buttons. I then tried resetting the Grid control dock property to "Fill"... however, it slides under the Panel rather than filling to its border, as I expected.

Is there any way to get the Grid control to use the remaining space and not resize under the docked Panel?
Bill2010  Thursday, March 26, 2009 7:53 PM

Hi Bill,

A controladded on a formalways tries tooccupy the remaining available space. In your scenario, the grid is the first control added on the form. If you set its Dock property to "Fill", it will occupy the entire client area of the form. So the behavior you see is by design.

To get what you want, you just need to adjust the order in which the grid and the Panel are added on the form. To do this, select menu View | Other Windows | Document Outline. In the Document Outline window, select the grid and click the Up arrow on the head of the window or select the Panel and click the Down arrow.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

  • Marked As Answer byBill2010 Wednesday, April 01, 2009 4:09 PM
  •  
Linda Liu  Wednesday, April 01, 2009 3:03 AM

Hi Bill,

A controladded on a formalways tries tooccupy the remaining available space. In your scenario, the grid is the first control added on the form. If you set its Dock property to "Fill", it will occupy the entire client area of the form. So the behavior you see is by design.

To get what you want, you just need to adjust the order in which the grid and the Panel are added on the form. To do this, select menu View | Other Windows | Document Outline. In the Document Outline window, select the grid and click the Up arrow on the head of the window or select the Panel and click the Down arrow.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu

  • Marked As Answer byBill2010 Wednesday, April 01, 2009 4:09 PM
  •  
Linda Liu  Wednesday, April 01, 2009 3:03 AM

You can use google to search for other answers

Custom Search

More Threads

• How do I make a group box visible after user input?
• UserControl Modifiers Property Default Value ???
• Classes not rebuilding in Visual Studio Project
• html edit control for winforms?
• Subclassing DateTimePicker to support DBNull values
• IExtenderProvider using a collection property...
• MdiContainer background Color C#
• C# Active Directory Contact List
• Anchor controls on Inherited forms
• Tablelayout Panel inherit problem