共用方式為


Shape.Hide 方法

對使用者隱藏線條或圖形控制項。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
Public Sub Hide
public void Hide()
public:
void Hide()
member Hide : unit -> unit
public function Hide()

備註

隱藏控制項就相當於設定Visible屬性設為false。 之後Hide呼叫方法時,Visible屬性會傳回值為false直到Show呼叫方法或直到Visible設為true。

範例

下列範例示範如何使用Hide和Show方法切換兩個圖形,在執行階段。 此範例中您需要RectangleShape名為 RectangleShape1 控制項和OvalShape名 OvalShape1 為表單上的控制項。 為求最佳效果,讓兩個控制項的大小相同,並置於彼此。

Private Sub Form1_Load() Handles MyBase.Load
    ' Hide the oval.
    OvalShape1.Hide()
End Sub 

Private Sub Shapes_Click() Handles RectangleShape1.Click, 
                                   OvalShape1.Click

    If OvalShape1.Visible = True Then 
        ' Hide the oval.
        OvalShape1.Hide()
        ' Show the rectangle.
        RectangleShape1.Show()
    Else 
        ' Hide the rectangle.
        RectangleShape1.Hide()
        ' Show the oval.
        OvalShape1.Show()
    End If 
End Sub
private void Form1_Load(System.Object sender, System.EventArgs e)
{
    // Hide the oval.
    ovalShape1.Hide();
}

private void Shapes_Click(System.Object sender, System.EventArgs e)
{
    if (ovalShape1.Visible == true)
    // Hide the oval.
    {
        ovalShape1.Hide();
        // Show the rectangle.
        rectangleShape1.Show();
    }
    else
    {
        // Hide the rectangle.
        rectangleShape1.Hide();
        // Show the oval.
        ovalShape1.Show();
    }
}

.NET Framework 安全性

請參閱

參考

Shape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)