How do I determine visibility of a control?

前端 未结 3 2210
温柔的废话
温柔的废话 2021-02-19 20:17

I have a TabControl that contains several tabs. Each tab has one UserControl on it. I would like to check the visibility of a control x on UserControl

3条回答
  •  北恋
    北恋 (楼主)
    2021-02-19 20:52

    Please try this:

    bool ControlIsReallyVisible(Control C)
    {
        if (C.Parent == null) return C.Visible;
        else return (C.Visible && ControlIsReallyVisible(C.Parent));
    }
    

提交回复
热议问题