Get Component's Parent Form

后端 未结 10 1031
再見小時候
再見小時候 2020-12-03 01:40

I have a non-visual component which manages other visual controls.

I need to have a reference to the form that the component is operating on, but i don\'t know how

10条回答
  •  忘掉有多难
    2020-12-03 02:07

    A improvement of above is:

    public static Form ParentForm(this Control ctrl) => ctrl as Form ?? ctrl.FindForm();
    

提交回复
热议问题