Board index » delphi » Set Width Button to Text...

Set Width Button to Text...

hi :o)

Does anybody know how to set the Width of a button to the lenght (widht) of
the text entered (a bit like entering text in labels), I supose it could be
done easy if you know how to get the size (in pixels) of a certain text.
But I have no idea how to get that size?

Anybody any ideas ?

Regards.

Alex

 

Re:Set Width Button to Text...


Try TextWidth: If your button1 is on Form1, you could try:

  Button1.Width:=Form1.Canvas.TextWidth("This is my text")+20;

Good luck.
Stefan Prins

Alex <Darkside_of_the_M...@msn.com> wrote in article
<01bc5ee9$80987fc0$951c86c2@alex->...

Quote
> hi :o)

> Does anybody know how to set the Width of a button to the lenght (widht)
of
> the text entered (a bit like entering text in labels), I supose it could
be
> done easy if you know how to get the size (in pixels) of a certain text.
> But I have no idea how to get that size?

> Anybody any ideas ?

> Regards.

> Alex

Other Threads