This is the Label2 source, which is formed on FormCreate :

  Label2.Font.Height:=24; Label2.Font.Name:='Trebuchet MS'; Label2.WordWrap:=True; Label2.Height:=64; Label2.Font.Color:=$ff0000; Label2.Width:=1000; 

Next comes the button with the Button2Click event, and nothing complicated happens to it, for Label2 doesn’t occur, much less its width changes. (width is generally no where does not change from the specified.)

Code on label2 in Button2

 r:=Random(r); Label2.Caption:=AdoQuery1.Fields[1].asString+' ['+IntToStr(r)+']'; 

And if you poke the button many times, then I noticed that the width of the Label2 tends to taper Label2 along the width, I think, it goes to the default value.
Label2 2-4-line questions, so it gradually turns into a column (!) Label2 6-10 or more lines.

Why it happens?

  • 3
    AutoSize = true? - Sergey
  • @Sergey is really true. Somehow I already forgot forgotten Delphi ... 10 years ago the last time, something serious was programming in it. - I_CaR

1 answer 1

It looks like the AutoSize = true property AutoSize = true .

Avoid using both AutoSize and WordWrap at the same time. they have mutually contradictory behavior (align width by content vs. align content by width)

Probably (you can check the source code VCL), something happens earlier, and something later, and it turns out that they inserted 123456, it split into 123-456, the width was folded, then 234567 was inserted, it broke into lines according to the width as 23 -45-67, and the new width is again reduced to match the new content, etc.