Delphi 11 应用程序中的 Splitter 无法按预期工作

问题描述 投票:0回答:1

我有一个带有两个面板和一个拆分器的表格。一个面板 (panel2) 右对齐,拆分器右对齐,第二个面板 (panel1) 客户端对齐。 当我将分割器向左移动时,panel2 的宽度按预期增加。当我将分离器移至右侧时,它会按预期减少。当我将分割器向右移动超过其 minSize 时,panel2 就会消失,分割器会一直向右移动,而 panel1 会占据客户区的所有其余部分。 我预计分离器不会移动超过 minSize,并且 panel2 将保持可见,其宽度等于分离器的 minSize。 这是一个测试应用程序

表格

object Form17: TForm17
Left = 0
Top = 0
Caption = 'Form17'
ClientHeight = 442
ClientWidth = 628
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
TextHeight = 15
object Splitter1: TSplitter
 Left = 440
 Top = 0
 Height = 442
 Align = alRight
 MinSize = 150
 ExplicitLeft = 360
 ExplicitTop = 216
 ExplicitHeight = 100
end
object Panel1: TPanel
 Left = 0
 Top = 0
 Width = 440
 Height = 442
 Align = alClient
 Caption = 'Panel1'
 TabOrder = 0
 ExplicitLeft = 64
 ExplicitTop = 104
 ExplicitWidth = 185
 ExplicitHeight = 41
end
object Panel2: TPanel
 Left = 443
 Top = 0
 Width = 185
 Height = 442
 Align = alRight
 Caption = 'Panel2'
 TabOrder = 1
 ExplicitLeft = 448
 ExplicitTop = 128
 ExplicitHeight = 41
end
end

代码

unit Unit17;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,         Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls;

type
  TForm17 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Splitter1: TSplitter;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form17: TForm17;

implementation

{$R *.dfm}

end.
delphi
1个回答
0
投票

这是设计好的。看看 splitter 的

AutoSnap
属性:

确定当使用分割器使相邻对象小于 MinSize 时是否将其大小调整为零。

AutoSnap 设置为 false,以防止当用户尝试使相邻对象小于 MinSize 时分割器将其大小调整为零。当 AutoSnap 为 false 时,此类调整大小尝试将被简单地阻止,从而使相邻对象的大小为 MinSize。 AutoSnap 的默认值为 true。

© www.soinside.com 2019 - 2024. All rights reserved.