PC Review


Reply
Thread Tools Rate Thread

Adjusting Button height

 
 
crosser
Guest
Posts: n/a
 
      21st Mar 2005
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


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      21st Mar 2005
"crosser" <(E-Mail Removed)> schrieb:
> 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%23KFHA.2804%40TK2MSFTNGP10.phx.gbl>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
J L
Guest
Posts: n/a
 
      21st Mar 2005
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

On Mon, 21 Mar 2005 13:44:07 +0100, "Herfried K. Wagner [MVP]"
<hirf-spam-me-(E-Mail Removed)> wrote:

>"crosser" <(E-Mail Removed)> schrieb:
>> 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%23KFHA.2804%40TK2MSFTNGP10.phx.gbl>


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      21st Mar 2005
"J L" <(E-Mail Removed)> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adjusting the height of an iframe to fit the contents. Cal Who Microsoft ASP .NET 2 1st Jun 2010 05:11 PM
RE: Adjusting the main form height David H Microsoft Access VBA Modules 0 10th Oct 2009 10:40 PM
Automatically adjusting Row height JoeP Microsoft Excel Misc 1 26th Nov 2007 10:55 PM
Adjusting button height by font size Bilz Microsoft Dot NET Framework Forms 3 29th Jan 2007 07:13 PM
Re: VBA for adjusting row height JE McGimpsey Microsoft Excel Misc 1 25th May 2004 07:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:13 AM.