I have designed a WinForms app with a several (nested) TableLayoutPanel containing background images and colors indicating status of hardware components. I added a PropertyGrid to display content of a specific object using the ComponentModel.
Example:
public class MyObject
{
public float Voltage;
[Category("Operation Voltage")]
[Description("Voltage applied")]
[DisplayName("Voltage")]
public float Vop { get => Voltage; }
}
I add the object to a PropertyGrid (the example is nonsense - only for illustration)
MyObject m = new MyObject();
m.Voltage = 1.234;
propertyGrid1.SelectedObject = m;
All works fine so far until I actively select the value in the PropertyGrid the actual value, selecting the category header has no side effect). If I do so, most TableLayoutPanel in my app start to flicker.
The problem is caused by (which I need for other purposes) this method described here:
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED
return cp;
}
}
Following this article here which describes the issue in my opinion I am supposed to release the "device context". Can anyone point out how to do that in case of a PropertyGrid?