我在状态栏中有两个(通常是n
个)状态面板。
该状态栏将始终在托管Windows窗体大小上定义调整大小。
现在,如何确保每个(或所有n
个)状态面板获得相同数量的状态栏宽度,以及如何确保它们从左到右堆叠得很好正如Panels
对象中的顺序所示?
答案 0 :(得分:-1)
只需添加一个函数即可将面板大小调整为表单上的Resize
事件。对于两个面板,您只需要在表单的初始化函数中添加类似这样的内容来处理调整大小。 (使用C#)
//To find to width of each panel, subtract 30 (or so, but your panels need to leave a little
//space) from the width of the form, and then divide by number of panels.
//Initialize the panel widths (If they aren't correct already)
statusBarPanel1.Width = statusBarPanel2.Width = (Width - 30) / 2;
//Make the panel widths update if the form is resized
Resize += (s, e) => statusBarPanel1.Width = statusBarPanel2.Width = (Width - 30) / 2;
面板的顺序不应该改变,所以你不必担心。