I have my own control derived from Windows.Forms.Control and I am checking the Parent.BackColor inside the overrided of OnHandleCreated() method. At desing-time the Parent property first returns null, then – after form is completely loaded – returns the real parent window: the form itself.
We need to draw part of the custom control with the same color of the parent form background: when can we rely on the Control.Parent value?
Thanks.
You can use the
ParentChangedevent to detect when that property changes and trigger a redraw (though one should occur automatically). There are some properties, however (BackColorandForeColorbeing two of them, I believe) that are “inherited” from the parent if not set explicitly, so you should be able to use those as well.