我想知道如何将 Button
对齐到 Center,或者极端 Left,或者极端 Right在 Panel
下方的位置。
我的麻烦是每次 Form
调整大小时 Button
永远不会停留在相同的位置。
例如 =>
- 表格最大化:
- 真实大小的表格(打开时):
最佳答案
使用 TRelativePanel作为布局组件。首先,将您的面板 upperPanel
放入其中。将 AlignHorizontalCenterWithPanel
和 AlignTopWithPanel
设置为 True
。然后,将您的按钮放在那里并将 Below
和 AlignRightWith
都设置为 upperPanel
。
更多信息: Using the Relative Panel
DFM(为方便起见而缩写)看起来像这样:
object Form1: TForm1
object RelativePanel1: TRelativePanel
Left = 0
Top = 0
Width = 537
Height = 169
ControlCollection = <
item
Control = upperPanel
AlignBottomWithPanel = False
AlignHorizontalCenterWithPanel = True
AlignLeftWithPanel = False
AlignRightWithPanel = False
AlignTopWithPanel = True
AlignVerticalCenterWithPanel = False
end
item
Control = collapseButton
AlignBottomWithPanel = False
AlignHorizontalCenterWithPanel = False
AlignLeftWithPanel = False
AlignRightWith = upperPanel
AlignRightWithPanel = False
AlignTopWithPanel = False
AlignVerticalCenterWithPanel = False
Below = upperPanel
end>
Align = alTop
BevelOuter = bvNone
TabOrder = 0
DesignSize = (
537
169)
object upperPanel: TPanel
Left = 143
Top = 3
Width = 250
Height = 41
Align = alTop
Caption = 'upperPanel'
Color = clSilver
ParentBackground = False
TabOrder = 0
end
object collapseButton: TButton
Left = 359
Top = 50
Width = 34
Height = 25
Anchors = []
Caption = '^'
TabOrder = 1
end
end
end
关于delphi - 如何将按钮对齐到面板下方的中心、左侧或右侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50206726/