如何在不使用 alClient 对齐的情况下调整 TGridPanel 内 TEdit 的大小

发布于 2024-12-03 00:00:07 字数 654 浏览 11 评论 0原文

我需要使用以下结构:

TEdit inside TGdridPanel inside TGridPanel

换句话说,存在一个 TGridPanel,并且在其中一个单元格中我需要插入其他 TGridPanel。

在此内部 TGridPanel 中需要插入两个 TLabel 和两个 TEdit,如下所示:

______________________

| T标签1 | TLabel 2 |

______________________

| T编辑 1 | TEdit 2 |

______________________

当我调整外部 TGridPanel 的大小时,内部 TGridPanel 也会调整大小,因为内部 TGridPanel 对齐是设置 alClient 的,当发生这种情况时,我想调整标签和编辑的大小如果它们锚定在左侧和右侧,但当它们位于 TGridPanel 内部时则不会,并且如果我将此内部组件的对齐设置为 alClient,它们就会扭曲。

我无法使用其他方式,因为我正在移动非常稳定的代码,并且无权更改它。

有人可以帮助我吗?

谢谢。

I need to work with the folow structure:

TEdit inside TGdridPanel inside TGridPanel

In others words, exist a TGridPanel and in one of the cells I need to insert other TGridPanel.

In this internal TGridPanel a need to insert two TLabels and two TEdits, like this:

______________________

| TLabel1 | TLabel 2 |

______________________

| TEdit 1 | TEdit 2 |

______________________

When I resize the external TGridPanel, the internal one resize too, because the internal TGridPanel align is setup alClient, and when this happend I want resize the Label's and the Edit's like if them was anchored on left and right, but it doesn't when they are inside the TGridPanel and if I set the align of the this internals components as alClient, they are distorted.

I can't use other way, because I'm moving in a code very stable and do not have permission to change it.

Could please somebody help me?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北渚 2024-12-10 00:00:07

屏幕截图可确保这就是您想要的...无需代码,只需设计...

在此处输入图像描述

< img src="https://i.sstatic.net/TYo9y.jpg" alt="在此处输入图像描述">

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 337
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object grdpnl1: TGridPanel
    Left = 0
    Top = 0
    Width = 635
    Height = 337
    Align = alClient
    Caption = 'grdpnlOutside'
    ColumnCollection = <
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end>
    ControlCollection = <
      item
        Column = 0
        Control = lbl1
        Row = 0
      end
      item
        Column = 1
        Control = lbl2
        Row = 0
      end
      item
        Column = 2
        Control = lbl3
        Row = 0
      end
      item
        Column = 0
        Control = lbl4
        Row = 1
      end
      item
        Column = 1
        Control = grdpnlInside
        Row = 1
      end
      item
        Column = 2
        Control = lbl5
        Row = 1
      end
      item
        Column = 0
        Control = lbl6
        Row = 2
      end
      item
        Column = 1
        Control = lbl7
        Row = 2
      end
      item
        Column = 2
        Control = lbl8
        Row = 2
      end>
    RowCollection = <
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end>
    ShowCaption = False
    TabOrder = 0
    ExplicitLeft = 144
    ExplicitTop = 64
    ExplicitWidth = 273
    ExplicitHeight = 105
    object lbl1: TLabel
      Left = 1
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitLeft = 91
      ExplicitTop = 50
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl2: TLabel
      Left = 212
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl3: TLabel
      Left = 423
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl4: TLabel
      Left = 1
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object grdpnlInside: TGridPanel
      Left = 212
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'grdpnlInside'
      ColumnCollection = <
        item
          Value = 50.000000000000000000
        end
        item
          Value = 50.000000000000000000
        end>
      ControlCollection = <
        item
          Column = 1
          Control = pnlBottomRight
          Row = 1
        end
        item
          Column = 0
          Control = pnlBottomLeft
          Row = 1
        end
        item
          Column = 0
          Control = pnlTopLeft
          Row = 0
        end
        item
          Column = 1
          Control = pnlTopRight
          Row = 0
        end>
      RowCollection = <
        item
          Value = 50.000000000000000000
        end
        item
          Value = 50.000000000000000000
        end>
      ShowCaption = False
      TabOrder = 0
      ExplicitLeft = 312
      ExplicitTop = 168
      ExplicitWidth = 185
      ExplicitHeight = 41
      object pnlBottomRight: TPanel
        Left = 105
        Top = 55
        Width = 105
        Height = 55
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 0
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          105
          55)
        object edtRight: TEdit
          Left = 0
          Top = 17
          Width = 105
          Height = 21
          Alignment = taRightJustify
          Anchors = [akLeft, akRight]
          TabOrder = 0
          Text = 'edtRight'
          ExplicitTop = 10
        end
      end
      object pnlBottomLeft: TPanel
        Left = 1
        Top = 55
        Width = 104
        Height = 55
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 1
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          104
          55)
        object edtLeft: TEdit
          Left = 0
          Top = 17
          Width = 105
          Height = 21
          Anchors = [akLeft, akRight]
          TabOrder = 0
          Text = 'edtLeft'
        end
      end
      object pnlTopLeft: TPanel
        Left = 1
        Top = 1
        Width = 104
        Height = 54
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 2
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          104
          54)
        object lblLeft: TLabel
          Left = 0
          Top = 20
          Width = 105
          Height = 13
          Anchors = [akLeft, akRight]
          AutoSize = False
          Caption = 'lblLeft'
        end
      end
      object pnlTopRight: TPanel
        Left = 105
        Top = 1
        Width = 105
        Height = 54
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 3
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          105
          54)
        object lblRight: TLabel
          Left = 0
          Top = 20
          Width = 105
          Height = 13
          Alignment = taRightJustify
          Anchors = [akLeft, akRight]
          AutoSize = False
          Caption = 'lblRight'
        end
      end
    end
    object lbl5: TLabel
      Left = 423
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl6: TLabel
      Left = 1
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl7: TLabel
      Left = 212
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl8: TLabel
      Left = 423
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
  end
end

The screenshots to be sure this is what you want... no code, just design...

enter image description here

enter image description here

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 337
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object grdpnl1: TGridPanel
    Left = 0
    Top = 0
    Width = 635
    Height = 337
    Align = alClient
    Caption = 'grdpnlOutside'
    ColumnCollection = <
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end>
    ControlCollection = <
      item
        Column = 0
        Control = lbl1
        Row = 0
      end
      item
        Column = 1
        Control = lbl2
        Row = 0
      end
      item
        Column = 2
        Control = lbl3
        Row = 0
      end
      item
        Column = 0
        Control = lbl4
        Row = 1
      end
      item
        Column = 1
        Control = grdpnlInside
        Row = 1
      end
      item
        Column = 2
        Control = lbl5
        Row = 1
      end
      item
        Column = 0
        Control = lbl6
        Row = 2
      end
      item
        Column = 1
        Control = lbl7
        Row = 2
      end
      item
        Column = 2
        Control = lbl8
        Row = 2
      end>
    RowCollection = <
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end
      item
        Value = 33.333333333333340000
      end>
    ShowCaption = False
    TabOrder = 0
    ExplicitLeft = 144
    ExplicitTop = 64
    ExplicitWidth = 273
    ExplicitHeight = 105
    object lbl1: TLabel
      Left = 1
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitLeft = 91
      ExplicitTop = 50
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl2: TLabel
      Left = 212
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl3: TLabel
      Left = 423
      Top = 1
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl4: TLabel
      Left = 1
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object grdpnlInside: TGridPanel
      Left = 212
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'grdpnlInside'
      ColumnCollection = <
        item
          Value = 50.000000000000000000
        end
        item
          Value = 50.000000000000000000
        end>
      ControlCollection = <
        item
          Column = 1
          Control = pnlBottomRight
          Row = 1
        end
        item
          Column = 0
          Control = pnlBottomLeft
          Row = 1
        end
        item
          Column = 0
          Control = pnlTopLeft
          Row = 0
        end
        item
          Column = 1
          Control = pnlTopRight
          Row = 0
        end>
      RowCollection = <
        item
          Value = 50.000000000000000000
        end
        item
          Value = 50.000000000000000000
        end>
      ShowCaption = False
      TabOrder = 0
      ExplicitLeft = 312
      ExplicitTop = 168
      ExplicitWidth = 185
      ExplicitHeight = 41
      object pnlBottomRight: TPanel
        Left = 105
        Top = 55
        Width = 105
        Height = 55
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 0
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          105
          55)
        object edtRight: TEdit
          Left = 0
          Top = 17
          Width = 105
          Height = 21
          Alignment = taRightJustify
          Anchors = [akLeft, akRight]
          TabOrder = 0
          Text = 'edtRight'
          ExplicitTop = 10
        end
      end
      object pnlBottomLeft: TPanel
        Left = 1
        Top = 55
        Width = 104
        Height = 55
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 1
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          104
          55)
        object edtLeft: TEdit
          Left = 0
          Top = 17
          Width = 105
          Height = 21
          Anchors = [akLeft, akRight]
          TabOrder = 0
          Text = 'edtLeft'
        end
      end
      object pnlTopLeft: TPanel
        Left = 1
        Top = 1
        Width = 104
        Height = 54
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 2
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          104
          54)
        object lblLeft: TLabel
          Left = 0
          Top = 20
          Width = 105
          Height = 13
          Anchors = [akLeft, akRight]
          AutoSize = False
          Caption = 'lblLeft'
        end
      end
      object pnlTopRight: TPanel
        Left = 105
        Top = 1
        Width = 105
        Height = 54
        Align = alClient
        BevelOuter = bvNone
        Caption = 'pnlBottomRight'
        ShowCaption = False
        TabOrder = 3
        ExplicitLeft = 136
        ExplicitTop = 72
        ExplicitWidth = 185
        ExplicitHeight = 41
        DesignSize = (
          105
          54)
        object lblRight: TLabel
          Left = 0
          Top = 20
          Width = 105
          Height = 13
          Alignment = taRightJustify
          Anchors = [akLeft, akRight]
          AutoSize = False
          Caption = 'lblRight'
        end
      end
    end
    object lbl5: TLabel
      Left = 423
      Top = 112
      Width = 211
      Height = 111
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl6: TLabel
      Left = 1
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl7: TLabel
      Left = 212
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
    object lbl8: TLabel
      Left = 423
      Top = 223
      Width = 211
      Height = 113
      Align = alClient
      Caption = 'lbl1'
      ExplicitWidth = 16
      ExplicitHeight = 13
    end
  end
end
盛装女皇 2024-12-10 00:00:07

使用内部 TGridPanel 的 OnResize 事件可以根据需要调整其子控件的大小。如果您希望它们填充整个区域,请使用内部 TGridPanel 的 ClientWidth/ClientHeight 来帮助计算尺寸。

Use the OnResize event of the inner TGridPanel to resize its child controls however you like. Use the inner TGridPanel's ClientWidth/ClientHeight to help calculate the sizes if you want them to fill the entire area.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文