0
我在狀態欄內有兩個狀態面板(或一般來說,數量爲n
)。狀態欄內的兩個狀態面板,如何確保它們總是佔據狀態欄的一半?
該狀態欄將始終在託管Windows窗體大小上定義調整大小。
現在,如何確保每個(或所有的n
數量)的狀態面板獲得等量的狀態欄寬度,以及如何確保它們按照指示從左到右很好地堆疊在對象中的順序?
我在狀態欄內有兩個狀態面板(或一般來說,數量爲n
)。狀態欄內的兩個狀態面板,如何確保它們總是佔據狀態欄的一半?
該狀態欄將始終在託管Windows窗體大小上定義調整大小。
現在,如何確保每個(或所有的n
數量)的狀態面板獲得等量的狀態欄寬度,以及如何確保它們按照指示從左到右很好地堆疊在對象中的順序?
只需添加一個函數來將面板大小調整爲表格上的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;
面板的順序不應該改變,所以你不必擔心。
我試過你的建議,通過手動設置面板寬度在窗體構造函數和表單加載事件,都不起作用。 – Graviton
它適用於我的測試。你也在Form Resize事件中設置寬度,對吧? –