I've been stuck on this problem for a bit, and I can't seem to wrap my head around where I am going wrong with this. I have a class UnitInfo
with several properties which are used to populate a PropertyGrid
in a winform. The properties:
public class UnitInfo {
public byte[] data { get; set; } = new byte[5];
public int serialNumber
{
get
{
return (int)data[0] & 0b0111_1111;
}
set
{
data[0] = (byte)(((int)data[0] & 0b1000_0000) | (int)value);
}
.
.
.
}
}
The rest of the properties are similar. When I update any property but data
in the PropertyGrid
the changes to data
are immediately shown. For example, if I change the serial number by manually typing a value into the PropertyGrid
then data
will update accordingly. However, the reverse isn't true. If I modify data
in the PropertyGrid
to change the value of the serialNumber
then data
will update but serialNumber
will not.
I may be wrong in my understanding of PropertyGrid
from reading through the docs, but shouldn't the Get
method of all properties be called when one is changed? That's what seems to be happening when any property modifies data
.
Why won't properties update when data
is modified?