Control difference between Hide() and Visible?

前端 未结 3 1867
陌清茗
陌清茗 2020-12-15 16:29

I was wondering about the difference between using a Control’s Hide() method compared to setting the Visible property to false.

When would

3条回答
  •  甜味超标
    2020-12-15 17:04

    They are equivalent. From the documentation for Control.Hide:

    Hiding the control is equivalent to setting the Visible property to false.

    You can confirm this with reflector:

    public void Hide()
    {
        this.Visible = false;
    }
    

    You might use Show() or Hide() when you know the value and use Visible when you take the visibility in as a parameter, although personally I would always use Visible.

提交回复
热议问题