Roger Luo

超越梦想一起飞
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C# Dock Style 设置

Posted on 2013-03-02 09:57  Roger Luo  阅读(5445)  评论(1编辑  收藏  举报

Assuming there are two panels in a winform, show like below.

Panel1 Panel2

Panel1.dock is left.

Panel2.dock is fill.

Right now, add a status bar at the bottom of this winform. Howerver, the status bar will located at the bottom under panel2, rahter than the bottom of this winform. Here is the sample.

x10sctmp

If choose the status bar on design of IDE, set it send to the back(置底), that the view of the panel should be like below:

x10sctmp0

The reason for this senario is that the order of control being added to theri parent. For more details, please check the designer.cs of the winform.

For the first case:

this.controls.add(statusbar);
this.controls.add(panel1);
this.controls.add(panel2);
For the second case:
this.controls.add(panel1);
this.controls.add(panel2);
this.controls.add(statusbar);
Indeed, the operation of “send to back” and “bring to front” just change the order of being added into parent container, in this case, parent container is the winform.
So if the dock style setting of the controls is not fit for your design, please consider change the order of this controls.