質問

I have a TableLayoutPanel within a FlowLayoutPanel so that I can have a 3D border around the table, but be able to define the positions of controls within the table as I wish. I would like to have the TableLayoutPanel fill the FlowLayoutPanel but when I use the docking property, the TLP seems to bunch up at the top of the FLP.

How can I get the TLP to dock so that it will resize when the form is resized?

役に立ちましたか?

解決

I generally find that Docking is more trouble than it's worth. In most cases Anchoring seems to work far better for me. Try disabling docking, then resizing the control so that it fills the panel they way you want, then setting it to anchor on left, right, top, and bottom.

Also, as others have mentioned, try using a normal panel instead of a FlowLayoutPanel. The specific layout panels have special code in them that handles resizing child elements that will probably interfere with your other resize logic.

ADDENDUM

Docking always snaps against the side of the container and forces the 2 sides on the other axis against the edges as well. Anchoring allows you to set specific positions and then tie one side of a control to it's parent so that resizing the parent keeps that side of the control the same distance from the parent. 99% of the time, in my experience, anchoring does everything that docking does and more, with far less frustration. I think that Splitterbars are the one of the few times that docking is required, but even then it can be emulated using a splitter panel. Things like ToolStrips and menus are the best use case for docking that I can think of.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top