Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Sun, 20 Jul 2008 19:19:23 -0600,    group: microsoft.public.dotnet.framework.windowsforms.controls        back       


LinkLabel - how long is the displayed text?   
Hi;

I need to get the size of the displayed text in a LinkLabel? How can I
do that?

thanks - dave

david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Sun, 20 Jul 2008 19:19:23 -0600   author:   David Thielen am

RE: LinkLabel - how long is the displayed text?   
Hello Dave,

Suppose a LinkLabel control named linkLabel1, we can get the font size of 
the displayed text by:

this.linkLabel1.Font.Size

The unit of measure is determined by 

this.linkLabel1.Font.Unit

whose value can be among the GraphicsUnit enumeration.
http://msdn.microsoft.com/en-us/library/system.drawing.graphicsunit.aspx

Please let me know if you have any other concerns, or need anything else.

Regards,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to 
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues 
where an initial response from the community or a Microsoft Support 
Engineer within 1 business day is acceptable. Please note that each follow 
up response may take approximately 2 business days as the support 
professional working with you may need further investigation to reach the 
most efficient resolution. The offering is not appropriate for situations 
that require urgent, real-time or phone-based interactions or complex 
project analysis and dump analysis issues. Issues of this nature are best 
handled working with a dedicated Microsoft Support Engineer by contacting 
Microsoft Customer Support Services (CSS) at 
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
date: Mon, 21 Jul 2008 05:22:28 GMT   author:   (Jialiang Ge [MSFT])

RE: LinkLabel - how long is the displayed text?   
Hello Dave,

I suddenly realize that you meant the length of the entire displayed text 
instead of its font size. If the 'AutoSize' property is true, we can 
retrieve the text length with the LinkLabel.Size.Width property; otherwise, 
we may need to call MeasureString to get the length of the text based on 
its font (LinkLabel.Font)
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.measurestrin
g.aspx

Regards, 
Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
date: Mon, 21 Jul 2008 06:18:22 GMT   author:   (Jialiang Ge [MSFT])

Re: LinkLabel - how long is the displayed text?   
Hi;

LinkLabel.Size seems to only grow, never shrink. Is there a way to get
it to reduce size when I give it new text and the new text is shorter?

thanks - dave


On Mon, 21 Jul 2008 06:18:22 GMT, jialge@online.microsoft.com
("Jialiang Ge [MSFT]") wrote:

>Hello Dave,
>
>I suddenly realize that you meant the length of the entire displayed text 
>instead of its font size. If the 'AutoSize' property is true, we can 
>retrieve the text length with the LinkLabel.Size.Width property; otherwise, 
>we may need to call MeasureString to get the length of the text based on 
>its font (LinkLabel.Font)
>http://msdn.microsoft.com/en-us/library/system.drawing.graphics.measurestrin
>g.aspx
>
>Regards, 
>Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
>Microsoft Online Community Support
>
>=================================================
>Delighting our customers is our #1 priority. We welcome your comments and 
>suggestions about how we can improve the support we provide to you. Please 
>feel free to let my manager know what you think of the level of service 
>provided. You can send feedback directly to my manager at: 
>msdnmg@microsoft.com.
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>=================================================


david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Mon, 21 Jul 2008 14:43:26 -0600   author:   David Thielen am

Re: LinkLabel - how long is the displayed text?   
Hello Dave,

Please make sure that LinkLabel.AutoSize is set to true beforehand. It 
grows and never shrink when AutoSize is false. Here is an example:

this.linkLabel1.AutoSize = true;

this.linkLabel1.Text = "1";
MessageBox.Show(this.linkLabel1.Size.Width.ToString());
this.linkLabel1.Text = "12";
MessageBox.Show(this.linkLabel1.Size.Width.ToString());
this.linkLabel1.Text = "1";
MessageBox.Show(this.linkLabel1.Size.Width.ToString());

The code outputs "98", "151", "98" on my side.

If this suggestion does not work for you, please you please give some code 
snippets that I can reproduce the problem?

Regards, 
Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and 
suggestions about how we can improve the support we provide to you. Please 
feel free to let my manager know what you think of the level of service 
provided. You can send feedback directly to my manager at: 
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
date: Tue, 22 Jul 2008 07:25:32 GMT   author:   (Jialiang Ge [MSFT])

Re: LinkLabel - how long is the displayed text?   
Hi;

Thank you - got it working. I think it requires some messages to fire
to happen (MessageBox causes everything to fire). I moved where I get
it and it works fine now.

thanks - dave

On Tue, 22 Jul 2008 07:25:32 GMT, jialge@online.microsoft.com
("Jialiang Ge [MSFT]") wrote:

>Hello Dave,
>
>Please make sure that LinkLabel.AutoSize is set to true beforehand. It 
>grows and never shrink when AutoSize is false. Here is an example:
>
>this.linkLabel1.AutoSize = true;
>
>this.linkLabel1.Text = "1";
>MessageBox.Show(this.linkLabel1.Size.Width.ToString());
>this.linkLabel1.Text = "12";
>MessageBox.Show(this.linkLabel1.Size.Width.ToString());
>this.linkLabel1.Text = "1";
>MessageBox.Show(this.linkLabel1.Size.Width.ToString());
>
>The code outputs "98", "151", "98" on my side.
>
>If this suggestion does not work for you, please you please give some code 
>snippets that I can reproduce the problem?
>
>Regards, 
>Jialiang Ge  (jialge@online.microsoft.com, remove 'online.')
>Microsoft Online Community Support
>
>=================================================
>Delighting our customers is our #1 priority. We welcome your comments and 
>suggestions about how we can improve the support we provide to you. Please 
>feel free to let my manager know what you think of the level of service 
>provided. You can send feedback directly to my manager at: 
>msdnmg@microsoft.com.
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>=================================================


david@at-at-at@windward.dot.dot.net
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
date: Wed, 23 Jul 2008 13:36:11 -0600   author:   David Thielen am

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us