Visual Studio 2008 Form Designer mixes boolean values

I have a very unpleasant problem that I am trying to solve in a couple of weeks. I have a WinForms C # project where I developed my own control (ListView + ToolStrip using ToolStripButtons). This control is used in different forms within the solution, but in other projects. For different forms, I need to make certain buttons visible or hidden, so I added the appropriate properties to my control, for example

    public Boolean DeleteButtonVisible
    {
        get
        {
            return tsbDelete.Visible;
        }
        set
        {
            tsbDelete.Visible = value;
        }
    }

Some buttons are visible by default, some are hidden. In the designer, when editing a form using my control, I can change these properties, the control buttons become visible or hidden, as they should. But every time I change something in my source file in all forms, these properties have reset values ​​by default, regardless of what I set in the constructor, and I need to restore these values ​​manually. Well, I use a control source, so it’s not so difficult, but doing “Cancel” on a couple of dozen files each time I change a little in another file is a hell of a disaster.

[DesignerSerializationVisibility], . "", - . "" , . "" , ...

- , .

- - ?

+3
1

, Control.Visible . , true , . , . , , , . , . :

    private bool tsbDeleteVisible;

    public bool DeleteButtonVisible {
        get { return tsbDeleteVisible; }
        set { tsbDelete.Visible = tsbDeleteVisible = value; }
    }

tsbDelete.Visible. , .

+2

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


All Articles