Get access to parent control from user control - C#

后端 未结 9 1803
甜味超标
甜味超标 2020-11-29 06:42

How do I get access to the parent controls of user control in C# (winform). I am using the following code but it is not applicable on all types controls such as ListBox.

9条回答
  •  醉梦人生
    2020-11-29 07:06

    Not Ideal, but try this...

    Change the usercontrol to Component class (In the code editor), build the solution and remove all the code with errors (Related to usercontrols but not available in components so the debugger complains about it)

    Change the usercontrol back to usercontrol class...

    Now it recognises the name and parent property but shows the component as non-visual as it is no longer designable.

提交回复
热议问题