Try the ReadOnlyAttribute
:
private int _myVar= 1;
[ReadOnly(true)]
public int MyVar {
get { return _myVar; }
}
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; }
}
Solution
Try the ReadOnlyAttribute
:
private int _myVar= 1;
[ReadOnly(true)]
public int MyVar {
get { return _myVar; }
}