tpanel.autosize purpose!? lazarus / 31-LCL ---------------------------------------------------------------------- speter · 2021-01-14 05:11 G'Day Folks, What is the intended purpose of TPanel's autosize property? If I place a TPanel on a form and set the autosize property to true, the panel basically disappears (width & height = 0). If I set the constraints MinHeight=25 & MinWidth=100, the panel is visible; but it is not resized to fit it's caption. I added a button and increased the caption's text in the onclick event handler... I normally use TPanels as containers - often setting the caption to ''; and never set the panel's autosize=true; but I decided today to use the panel to display a message (rather than putting a TLabel in the panel, which is my normal practice). I am not sure whether this is a bug or a feature! It certainly isn't a big deal. cheers S. PS: I think I found the answer; if I put a button in the panel; then set the panel.autosize=true (in the designer); then the panel basically matches the button's size... ---------------------------------------------------------------------- lucamar · 2021-01-14 09:38 Quote from: speter on January 14, 2021, 06:11:59 amPS: I think I found the answer; if I put a button in the panel; then set the panel.autosize=true (in the designer); then the panel basically matches the button's size... Yes, that's what it's for, to match the panel's size to its contents (plus border spacing, etc.). How is usually used is that one first fills up the panel with whatever other controls one needs and as a last step sets Autosize to true; otherwise, on an empty panel, it diminish to nothing, to match its ... well, its non-existent "content" ---------------------------------------------------------------------- jamie · 2021-01-14 22:09 yeah, maybe it shouldn't auto size with no child controls. ---------------------------------------------------------------------- lucamar · 2021-01-15 02:13 Quote from: jamie on January 14, 2021, 11:09:27 pmyeah, maybe it shouldn't auto size with no child controls. Depends of what you mean to do with it, because this behaviour lends itself to some stunning* effects if you create its contents at run- time depending on some conditions and/or you want it to "auto- dissapear" if left empty but be there as e.g. a placeholder; and you can always use constraints if you want an empty panel to, say, mimic a button or something like that. As such it's safest, IMHO, that when you order it to Autosize it does so, whatever the outcome. * OK, maybe calling it "stunning" is stretching words a bit ...