2

サイドバーが添付されたアプリケーション ( TPanel--> alRight) があり、その中で CategoryPanel ( alClient) を使用しています。この CategoryPanel には、整列していない正確に 2 つのグループがあります。これら 2 つのグループの境界を共有して、パネル スペース全体を 50/50 の比率で埋めたいと思います。残念ながら、CategoryGroups は設計時のアライメントをサポートしていないため、テストするたびにアプリケーションを実行する必要があります。各 CategoryGroup をパネルの半分の高さに設定しようとしましたが、スクロールバーが表示されます。(写真2参照)

境界を 50/50 の比率で適切に整列/共有するにはどうすればよいですか?

画像1 画像2

4

1 に答える 1

5

あなたのコメントによると、次のコードを実行したいと考えています。

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;
于 2013-05-21T12:59:10.727 に答える