Locking a Form in Position

Locking a Form in Position

Question:
How do you lock down a form so that when the program is run, you can not move it. What I want to do is have one main form, with another smaller form within it. I want to lock the smaller form in place so it can not be moved around. The only way I have been able to do this is to disable the form. But I need the form enabled. How would I accomplish this?

Answer:
I would recommend using the Paint event to position the form to aparticular X, Y coordinate pair. The Paint event is called whenever theform is drawn or moved. Just set the Top and Left properties of the formto your preselected values and the form will appear to be locked in place.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist