Jump to content
Hafedh TRIMECHE

TPanel and AutoSize problem (Delphi 11)

Recommended Posts

Works perfectly with a simple test program. Probably some settings on your side. Can you attach a small example so that we can see a bit more?

Share this post


Link to post

It also depends on where you placed the panel. And what neighbors I have. With what settings.

Share this post


Link to post
object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 441
  ClientWidth = 624
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  PixelsPerInch = 96
  TextHeight = 15
  object Panel1: TPanel
    Left = 96
    Top = 32
    Width = 185
    Height = 41
    AutoSize = True
    Caption = 'Panel1'
    TabOrder = 0
  end
end

 

bds_CUKVPgahRs.png

Share this post


Link to post

And to what controls are you expecting the panel to adjust its size?

Or more general, what do you think what AutoSize does?

Share this post


Link to post

Setting AutoSize of a panel to true makes the panel adjust its size so that all contained controls are still visible, but nothing more. It takes AdjustWithMargins of the controls into account. The panel Align value takes precedence over the AutoSize.

Share this post


Link to post
30 minutes ago, Hafedh TRIMECHE said:

When a Panel is empty (no controls) it would adjust its size to the text width as it is done when using a TLabel.

This is what TAdvPanel does:classic_smile:

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×