C # WinForm Control Lock

In the program I wrote, users can add controls to the form and move them and set some properties in pseudo-project mode. I want to lock all these controls in one place when they press a button to switch to "data mode". How can i do this? I wanted so that I could skip all the controls and use the lock property, but I noticed that it did not appear in intellisense.

Thanks!

+3
source share
3 answers

I assume that “pseudo-project mode” means that your application is at runtime and the end user is experiencing “virtual design mode”: please correct me if I am wrong.

But I assume that you mean Locked lock time for controls and that you want to "emulate" this at runtime ... right?

I also suggest that you attach the mouse up / down / move handlers to the controls that you allow to move, perhaps by iterating over all or a subset of the controls in the form (or the collection that you save the controls are allowed to move).

, , , , , .

, , itho, " " ( " " ... ).

: "" " ": , : " ", "" " . :

  • hostingForm.ActiveControl, , mousedown (, , ): , , , .

  • "z-order", , , , , , , .

imho, , , , , "" "" :

private void enableControlsMove()
{
    foreach (Control theControl in panel1.Controls)
    {
        Console.WriteLine(theControl.Name);

        theControl.MouseDown += new MouseEventHandler(theControl_MouseDown);
        theControl.MouseUp += new MouseEventHandler(theControl_MouseUp);
        theControl.MouseMove += new MouseEventHandler(theControl_MouseMove);
    }
}

private void disableControlsMove()
{
    foreach (Control theControl in panel1.Controls)
    {
        Console.WriteLine(theControl.Name);

        theControl.MouseDown -= theControl_MouseDown;
        theControl.MouseUp -= theControl_MouseUp;
        theControl.MouseMove -= theControl_MouseMove;
    }
}

.

,

+2

Locked - Windows Forms (, Generate Member and Modifiers "). , , ( ) (, , ) , .

+3

. "" .

MSDN

, . , - " ".

Update: It seems that custom designer classes can add properties to controls based on whether they are in development mode or not.
More information is available here if you intend to use the VS architectural hammer path. In any case, it costs 10 minutes to read.
Custom Development Time Management Features in Visual Studio .NET - Dino Esposito

+2
source

Source: https://habr.com/ru/post/1721836/


All Articles