public int CalculateHeight(Label lbl) { Graphics g = lbl.CreateGraphics(); return Convert.ToInt32(g.MeasureString(lbl.Text, lbl.Font).Width); } private void button1_Click(object sender, EventArgs e) { label1.Text = "The Computer location is now called This PC, and you can still use the Documents, Music, Pictures, and Videos folders to save your files. You just browse to these folders differently in File Explorer. To browse the locations on your PC, including the folders that used to appear under Libraries, expand This PC in the left pane. "; //label1.Text = "The Computer location is now called This PC, and you can still use the Documents, Music, Pictures, and Videos folders to save your files."; label1.Height = CalculateHeight(label1) / 14; MessageBox.Show(label1.Height.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)