根據您的意見,您要運行該代碼:
procedure TForm1.UpdateGroupHeights;
begin
if not CategoryPanel1.Collapsed then
CategoryPanel1.Height := CategoryPanelGroup1.ClientHeight div 2;
if not CategoryPanel2.Collapsed then
CategoryPanel2.Height := CategoryPanelGroup1.ClientHeight -
CategoryPanelGroup1.ClientHeight div 2;
end;
每當有什麼變化,你想影響你組的佈局。所以我認爲你需要從以下事件中調用這個函數:
- 該事件的形式爲
OnCreate
。
OnResize
事件TCategoryPanelGroup
。
OnCollapse
和OnExpand
事件的兩個類別面板。
雖然一個面板摺疊而另一個面板展開,但看起來有點奇怪。我個人會重新調整代碼以填充所有可用空間。
if not CategoryPanel1.Collapsed then
;//nothing to do
if CategoryPanel1.Collapsed and not CategoryPanel2.Collapsed then
CategoryPanel2.Height := CategoryPanelGroup1.ClientHeight-CategoryPanel1.Height;
if not CategoryPanel1.Collapsed and CategoryPanel2.Collapsed then
CategoryPanel1.Height := CategoryPanelGroup1.ClientHeight-CategoryPanel2.Height;
if not CategoryPanel1.Collapsed and not CategoryPanel2.Collapsed then
begin
CategoryPanel1.Height := CategoryPanelGroup1.ClientHeight div 2;
CategoryPanel2.Height := CategoryPanelGroup1.ClientHeight-CategoryPanel1.Height;
end;
當類別組關閉時,您希望發生什麼? –
如果他們崩潰了,什麼都不應該發生,大小隻是保持不變。 –