Created
May 6, 2014 07:07
-
-
Save abhi1010/e8390c5868a86998a7d5 to your computer and use it in GitHub Desktop.
Dynamically Resize 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 = Graphics.FromHwnd(this.Handle); //gets the graphics form the form | |
SizeF size = g.MeasureString(label1.Text, 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