Control resize and positioning at run time. VB.Net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TechNik
    New Member
    • Oct 2008
    • 1

    #1

    Control resize and positioning at run time. VB.Net

    Can any one help me, regarding resizing and positioning a control at run time in VB.Net.
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    Originally posted by TechNik
    Can any one help me, regarding resizing and positioning a control at run time in VB.Net.
    Well, to start off with, you can set the control's size by using the Control.Size Property. Also, you can set the position(or location I think you are referring to) by using the Control.Locatio n Property.

    Here's a sample code to increase a button's, the control's, size each time you click on the button.

    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                button1.Size = new Size(button1.Width + 5, button1.Height + 5);
            }
    To change the location of the control, the following code may be useful: It changes the location by adding 5 pixels to both the button's X and Y coordinates.

    Code:
            private void button1_Click(object sender, EventArgs e)
            {
                button1.Location = new Point(button1.Location.X + 5, button1.Location.Y + 5);
            }
    Those are just sample snippets to get you familiar with using those properties. I'd also like to point out that you've posted this in the wrong forum. So, I will ask an Admin to move it to the proper forum. Please read thoroughly through the Posting Guidelines as you are a new member.

    Also, I just noticed you're in VB.NET, and I've given code in C#. If you cannot translate the code off hand then have a look at this site as it will help you in comparing the differences between the two languages and help you translate it.

    joedeene

    Comment

    Working...