locked
Labels move at runtime RRS feed

  • Question

  • The position of my labels won't remain fixed during run time whenever i've added a background picture to my form. What should i do so that my labels remain fixed at one position at run time. I've tried locking them and also locking the form but the labels still move a few pixels from their original position.
    Wednesday, January 4, 2012 11:39 AM

Answers

  • Hi Kain..

    Welcomes you to MSDN forums.

    Ad this code in your form load event.

     Label1.Location = New Point(12, 54) 'Here add your lable needed location point 
     Label1.BringToFront()
    

    I hope it will helps to you..
    By

    A Pathfinder..

    JoSwa


    If you find an answer helpful, click Vote as helpful button. If you find an answer to your question, Click mark it as the answer.
    • Proposed as answer by Mark Liu-lxf Friday, January 6, 2012 5:05 AM
    • Marked as answer by Mark Liu-lxf Friday, January 13, 2012 8:58 AM
    Wednesday, January 4, 2012 12:11 PM
  • Hello kainat21,

    Usually this happens when a control such as a label is place on a form and at run time the form is resized, the control stays relative to the form's original size not the new size. Have not seen this happen by simply changing a background picture on a form, only when changing a form's size.

    I would suggest setting the Achor property differently, for instance if the label was in the top right corner of the form, select the label, open the property window, under Layout select Anchor then set Anchor to Top,Right then rebuild and run the project under the same conditions. Does this help or not?


    KSG
    • Proposed as answer by Mark Liu-lxf Friday, January 6, 2012 5:06 AM
    • Marked as answer by Mark Liu-lxf Friday, January 13, 2012 8:58 AM
    Wednesday, January 4, 2012 12:13 PM

All replies

  • Hi Kain..

    Welcomes you to MSDN forums.

    Ad this code in your form load event.

     Label1.Location = New Point(12, 54) 'Here add your lable needed location point 
     Label1.BringToFront()
    

    I hope it will helps to you..
    By

    A Pathfinder..

    JoSwa


    If you find an answer helpful, click Vote as helpful button. If you find an answer to your question, Click mark it as the answer.
    • Proposed as answer by Mark Liu-lxf Friday, January 6, 2012 5:05 AM
    • Marked as answer by Mark Liu-lxf Friday, January 13, 2012 8:58 AM
    Wednesday, January 4, 2012 12:11 PM
  • Hello kainat21,

    Usually this happens when a control such as a label is place on a form and at run time the form is resized, the control stays relative to the form's original size not the new size. Have not seen this happen by simply changing a background picture on a form, only when changing a form's size.

    I would suggest setting the Achor property differently, for instance if the label was in the top right corner of the form, select the label, open the property window, under Layout select Anchor then set Anchor to Top,Right then rebuild and run the project under the same conditions. Does this help or not?


    KSG
    • Proposed as answer by Mark Liu-lxf Friday, January 6, 2012 5:06 AM
    • Marked as answer by Mark Liu-lxf Friday, January 13, 2012 8:58 AM
    Wednesday, January 4, 2012 12:13 PM