效果图:

Delphi 动态改变Rzsplitter的Orientation(方向)属性

原先不知道,弄了半天都改不了RzSplitter.Orientation = orHorizontal / orVertical

然后去查该组件的源代码,原来Orientation不是在RzSplit单元定义的,而是在RzCommon这个单元,uses它后,一切正常了。

RzCommon Unit
//...
type
  TAlignmentVertical = ( avTop, avCenter, avBottom );

  TBlinkState = ( bsOn, bsOff );

  TTextStyle = ( tsNormal, tsRaised, tsRecessed, tsShadow );
  TOrientation = ( orHorizontal, orVertical );  //此处
  TBarStyle = ( bsTraditional, bsLED, bsGradient );
  TLineStyle = ( lsNone, lsFlat, lsGroove, lsBump );
//Button1 的 OnClick事件
procedure TForm1.Button1Click(Sender: TObject);
var
  w, h: Integer;
begin
  w := Ceil((RzSplitter1.UpperLeft.Pane.Height / RzSplitter1.Height) * RzSplitter1.Width);  //width
  h := Ceil((RzSplitter1.UpperLeft.Pane.Width / RzSplitter1.Width) * RzSplitter1.Height);  //height
  if RzSplitter1.Orientation = orHorizontal then
  begin
    RzSplitter1.Orientation := orVertical;
    RzSplitter1.UpperLeft.Pane.Height := h;
    RzSplitter1.Position := RzSplitter1.UpperLeft.Pane.Height;
    Button1.Caption := 'Vertical (垂直铺设)';
  end
  else
  begin
    RzSplitter1.Orientation := orHorizontal;
    RzSplitter1.UpperLeft.Pane.Width := w;
    RzSplitter1.Position := RzSplitter1.UpperLeft.Pane.Width;
    Button1.Caption := 'Horizontal (水平铺设)';
  end;

end;

  

  

相关文章:

  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
  • 2021-09-23
  • 2021-12-24
  • 2021-06-21
  • 2021-10-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案