Control 'seems' to be locked

2019-04-18 19:08发布

问题:

I'm trying to change properties to a control however it seems as if it's "locked" but in reality, it isn't because when I right-click on the control it shows the control as being unlocked.

I'm using Visual Studio 2005, and I've never worked with a control that seems to be locked as such in the picture provided.

I'd really appreciate a simple explanation and how to resolve this issue so that I can proceed with modifying it.

回答1:

This will happen when you try to design an inherited form and the control(s) on that form are private. The designer observes accessibility modifiers. Go back to the base form and change the Modifiers property of the controls from Private to Protected.



回答2:

Right click on the form and uncheck option "lock controls"

This should help.



回答3:

If you have form A which name is "Form.cs" in your project, classes from other form's (B, C, D, etc.) will be inheritance class "Form.cs" from your "A"... it should inheritance System.Windows.Forms.Form. Just try change your A forms class name from "Form.cs" to "Form1.cs".



回答4:

I was suffering exactly the same issue but it was just happening with DevExpress controls.

After some hours of changing modifiers and shooting myself in the feet I found this option on Visual Studio => DevExpress => WinForms Controls vX.X.X => Change Design-Time settings => Enable visual inheritance for Developer Express controls used in Visual Studio.



回答5:

When you are adding a new Inherited form, and want to have all controls unlocked, go to the Form you are Inheriting from, select Designer.cs file and change the controls you want changed to protected. Once that is done, build your solution and then create the inherited form. The controls should become unlocked.



回答6:

Go to the base code of the form solution explorer--> formXX --> Dispose(Boolean) and change inheritance line to Inherits System.Windows.Forms.Form