I think that the parent is not yet available because the control was not added yet to a form or control.
Try executing the code inside the Load or ParentChanged event handlers.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Dear All,
I get an error as follows. The codes of the application are shown below the screen capture.
I think that the parent is not yet available because the control was not added yet to a form or control.
Try executing the code inside the Load or ParentChanged event handlers.
When writing your code to read the value of .Parent, you should consider that null is a valid input, as documented by Microsoft in places such as
Setting .Parent to null explicitly has its meaning. And if you don't like that, you should assign whatever you like to .Parent when creating such UI controls.