Re: Resizing a button

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Tim Wilson ("Tim)
Date: 03/23/05


Date: Tue, 22 Mar 2005 23:11:29 -0500

Are you taking the borders into consideration? For a 3D-bordered button you
will need to add (SystemInformation.Border3DSize.Width * 2).

-- 
Tim Wilson
.Net Compact Framework MVP
"Z" <Z@discussions.microsoft.com> wrote in message
news:E1C9D3D3-9CEB-46B3-B3CC-3A7E09FF5D78@microsoft.com...
> Hi,
>
> I want to resize a button depending on its label.
> I do this:
>
> // In Form1 ctor
> Graphics gr=button1.CreateGraphics(); //
> button1.Size=gr.MeasureString(button1.Text, button1.Font).ToString();
>
> but the buttin misses the last letter. It wont work even if I round up the
> SizeF value returnde from MeasureString. It works only if I use this code:
>
> button1.Size=gr.MeasureString(button1.Text+/*add offset*/"W",
> button1.Font).ToString();
>
>
> Thanks
>

Quantcast