Created
May 6, 2014 07:08
-
-
Save abhi1010/f488949a5d79b6d86544 to your computer and use it in GitHub Desktop.
Auto Resize a Label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Resize(Label label1) | |
{ | |
Graphics g = this.CreateGraphics(); //gets the graphics based on the client area | |
SizeF size = g.MeasureString(str, label1.Font); //gets the size of the text which will be displayed | |
label1.Size = new Size((int)size.Width, label1.Size.Height); //sets the length of the label (same height) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment