I have a UserControl that uses some public properties that I have in my form, at the top of the Paint event for this UserControl , I refer to the Parent of the control and overlay this to the type of my Form.
var _parent = (Form1)Parent;
This code works, however, an error occurs in the Design view, and everything that I see instead of UserControl is a white frame that displays an error in the header of this message. A glass line leads directly to this line of code.
I have currently fixed this error by re-redirecting this action using the property in my UserControl
public Form1 ControlParent { get { if (Parent != null) { return (Form1)Parent; } return null; } }
It's a bit for something that just breaks the design view .. any other ideas?
source share