C# Dock Style 設置


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.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM