Get access to parent control from user control - C#

后端 未结 9 1866
甜味超标
甜味超标 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:02

    Control has a property called Parent, which will give the parent control. http://msdn.microsoft.com/en-us/library/system.windows.forms.control.parent.aspx

    eg Control p = this.Parent;

提交回复
热议问题