locked
Anchor/Docking problems... RRS feed

  • Question

  • Is there any good documentation anywhere that explains these properties in detail. Everything I found out there is awful. What I'm trying to do should be simple to do, but I haven't found a way to do it with either Anchor or Dock or any combination.

    Basically, I have 9 TextBoxes. When the form gets re-sized I want all 9 TextBoxes to resize as well being anchored in the top-left corner of the form. So basically, I want the 9 TextBoxes to stay in relative position to each other, but increase in size to the right and down.

    Any ideas?
    Thursday, July 12, 2007 9:45 PM

Answers

  • Bruno,

    Thanks for the help. I finally got it working using a TableLayoutPanel. It wasn't easy, but here's what I ended up doing:

     

    (1) Create a TableLayoutPanel with 3 Rows and 3 Columns with columns and rows set to Percent.

    (2) Create a Panel for each of the 9 boxes created by step 1.

    (3) Set the Dock to Fill for each of these panels.

    (4) Create a RichTextBox for each of the Panels.

    (5) Set the RichTextBox to Fill.

     

    I also wanted a little label in the top left corner of the RichTextBox. This is the reason for the extra panels. Without the extra panels, you are limited to one control per TableLayoutPanel...

    Friday, July 13, 2007 8:00 PM

All replies

  • You should use a container, probably a tablelayoutpanel, you anchor the table layout panel, you choose next how your rows and columns to be sized in percent, this way you get your relative behavior.
    Anchor a control to a container border mean maintaining distance.
    Docking means having the control fill the container(or a side of the container).

    hope this helped
    Thursday, July 12, 2007 10:35 PM
  • Bruno,

    Thanks for the help. I finally got it working using a TableLayoutPanel. It wasn't easy, but here's what I ended up doing:

     

    (1) Create a TableLayoutPanel with 3 Rows and 3 Columns with columns and rows set to Percent.

    (2) Create a Panel for each of the 9 boxes created by step 1.

    (3) Set the Dock to Fill for each of these panels.

    (4) Create a RichTextBox for each of the Panels.

    (5) Set the RichTextBox to Fill.

     

    I also wanted a little label in the top left corner of the RichTextBox. This is the reason for the extra panels. Without the extra panels, you are limited to one control per TableLayoutPanel...

    Friday, July 13, 2007 8:00 PM