|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
How to set Autosize Label .NET Framework I wanted to create an application in which i wanted to create an Label and for that i have decided to develop in using .NET framework, and i have also read that label control has a AutoSize property, which wraps the text if it doesn't fit into specified label width. How do I set the property values in the autosize label I would like to have same capability on Compact Framework. |
#2
| |||
| |||
Re: How to set Autosize Label .NET Framework You may use the following code for your autosize label or something similar to it. Code: Graphics Z = this.create_Graphics(); SizeF set_Size = Z.MeasureString(str, label1.Font); //get the size of the text label1.set_Size = new Size((int)size.Width, label1.Size.Height); //set the size of the label |
#3
| |||
| |||
Re: How to set Autosize Label .NET Framework Gets or sets a value indicating whether the control is automatically resized to display its entire contents. Namespace: System.Windows.Forms Assembly: System.Windows.Forms (in System.Windows.Forms.dll) Visual Basic (Declaration) Code: <BrowsableAttribute(True)> _ Public Overrides Property AutoSize As Boolean Code: Dim instance As Label Dim value As Boolean value = instance.AutoSize instance.AutoSize = value |
#4
| |||
| |||
Re: How to set Autosize Label .NET Framework while searching for how to set Autosize Label on the internet I found this. Try this in your application. Code: public void Resize(Label label1) { Graphics P = Graphics.FromHwnd(this.Handle); SizeF set_Size = P.MeasureString(label1.Text, label1.Font); //gets the size of the text which will be displayed label1.set_Size = new set_Size((int)size.Width, label1.Size.Height); //sets the length of the label (same height) } |
![]() |
|
Tags: autosize, dot net framework, framework, label |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
.NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x86 | M.Scarlet | Server Update Service | 10 | 05-05-2011 11:13 AM |
.net Compact Framework autosize textbox | Avanindra | Software Development | 2 | 04-06-2009 07:24 PM |
How do i get same compact label autosize in .net | Dharmesh Arora | Software Development | 2 | 19-05-2009 02:02 PM |
Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 3.5 Family Update (KB951847) x64 Installation problem | BP | Windows Update | 8 | 16-03-2009 08:29 AM |
How to Disable Autosize of Images in Internet Explorer and Firefox | Mastermind | Tips & Tweaks | 0 | 21-01-2009 08:13 PM |