Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Adjust the height of labels location and autosize to content

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 255
    Answer it

    I create a user control. i have label (labe1, label2, label3). this labels have auto size property to false, and the user control scale base on the combine height of the three labels. 

    My problem is the height of the labels work fine but their location is always fixed. they don't base on the content scalability. I want I such a away that the moment label1 scale to fit parent container, so does the label2 to shift up base on the label1 bottom not stay fixed. A tried un-anchoring  them but no result.

    Graphics g = CreateGraphics();
                SizeF size = g.MeasureString(label1.Text, label1.Font, label1.Width);
    
                label1.Height = int.Parse(Math.Round(size.Height + 2, 0).ToString());
                label10.Height = int.Parse(Math.Round(size.Height + 2, 0).ToString());
    
                label10.Location = new Point(label1.Left, label1.Bottom);
                label9.Location = new Point(label10.Left, label10.Bottom);
                this.Height = label9.Bottom + 35;

     

 0 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: