あなたのコメントによると、次のコードを実行したいと考えています。
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
。
- 2 つのカテゴリ パネルの
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;