Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-lock-controls-to-windows-forms.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

2.1 KiB

title, ms.date, helpviewer_keywords, ms.assetid, author, ms.author, manager
title ms.date helpviewer_keywords ms.assetid author ms.author manager
Lock Controls 03/30/2017
Windows Forms controls, locking
controls [Windows Forms], locking
94efe0d2-c14e-4d14-b903-63ea9b07e290 jillre jillfra jillfra

How to: Lock controls to Windows Forms

When you design the user interface (UI) of your Windows application, you can lock the controls once they are positioned correctly, so that you do not inadvertently move or resize them when setting other properties.

Additionally, you can lock and unlock all the controls on the form at once, which is helpful for forms with many controls, or you can unlock individual controls. Once you have placed all the controls where you want them on the form, lock them all in place to prevent erroneous movement.

To lock a control

In the Properties window of Visual Studio, select the Locked property and then select true. (Double-clicking the name toggles the property setting.)

Alternatively, right-click the control and choose Lock Controls.

Note

Locking controls prevents them from being dragged to a new size or location on the design surface. However, you can still change the size or location of controls by means of the Properties window or in code.

To lock all the controls on a form

From the Format menu, choose Lock Controls.

Note

This command locks the form's size as well, because a form is a control.

To unlock all locked controls on a form

From the Format menu, choose Lock Controls.

All previously locked controls on the form are now unlocked.

To unlock locked controls individually

In the Properties window, select the Locked property and then select false. (Double-clicking the name toggles the property setting.)

See also