Change location of control at runtime in C#


Beginners of C# who were familiar with VB6 may try to move the control using left and top properties of the control. It works fine with the Visual Basic 6. In Visual Studio the conceptĀ is changed with Location.

A location has two coordinates, namely x and y, similar to Top and Left in VB6. A location is an object of class Point. So we can change the location of a control using a new point object.

In the following, I have a panel, which I want to move at the run time to another part of the window.

stockpanel.Location = new Point(250, 5);

That’s it.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.