Adjusting Button height

  • Thread starter Thread starter crosser
  • Start date Start date
C

crosser

Hi, I want to adjust button height based on label text.

Normally I have standard height because label text has one row, but the text
can change in runtime.
I want to adjust height of the button after text change, if the text is too
long and wraps to the second row and 3rd, and so on. The width of the button
never changes.

In other way I want to measure how much place takes text and adjust the size
od the button to show entire text.

regards,
Crosser
 
crosser said:
Hi, I want to adjust button height based on label text.

Normally I have standard height because label text has one row, but the
text can change in runtime.
I want to adjust height of the button after text change, if the text is
too long and wraps to the second row and 3rd, and so on. The width of the
button never changes.

You can measure the text shown in the label using 'Graphics.MeasureString'
and then adjust the size of the button accordingly:

<URL:http://groups.google.de/groups?selm=eH5Ait#[email protected]>
 
Hi Herfried,
Can you apply Graphics.MeasureString to other text such as the text in
a listview's column header? I tried to but the .Text property did not
support CreateGraphics. So is this just for Lables?

TIA,
John
 
J L said:
Can you apply Graphics.MeasureString to other text such as the text in
a listview's column header? I tried to but the .Text property did not
support CreateGraphics. So is this just for Lables?

The text in listview controls is drawn using GDI, so 'MeasureString' isn't
very useful in this situation at all.
 
Back
Top