Question

I want to create a variable (int) read-only in the Property Grid.

There is something I do not understand.

The variable is without set, why it still allows me to change the value (and fall when it fails to put the value into the variable)?

    private int _myVar= 1;

    public int MyVar
    {
        get { return _myVar; }
    }
Was it helpful?

Solution

Try the ReadOnlyAttribute:

private int _myVar= 1;

[ReadOnly(true)]
public int MyVar {
    get { return _myVar; }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top