如何使用代码停靠在父容器中

时间:2011-02-13 07:39:43

标签: .net vb.net winforms dock

如何使用代码将报表查看器控件停靠到其父容器中。

2 个答案:

答案 0 :(得分:1)

将控件的Dock property设置为停靠到其父容器的所有边。例如:

reportViewer.Dock = DockStyle.Fill


所有可用的停靠选项均由DockStyle enumeration提供,总结如下:

Name       Description
-----------------------------------------------------------------
None      Not docked.
Top       Top edge is docked to the top of its containing control.
Bottom    Bottom edge is docked to the bottom of its containing control.
Left      Left edge is docked to the left edge of its containing control.
Right     Right edge is docked to the right edge of its containing control.
Fill      All edges are docked to the edges of its containing control and sized appropriately.

答案 1 :(得分:0)

如果您不相信对接,您可以回复父容器的OnSize事件,并根据父母手动重新定位/调整控件的大小。