Control.Visible 속성

정의

컨트롤과 모든 해당 자식 컨트롤이 표시되는지를 나타내는 값을 가져오거나 설정합니다.

public:
 property bool Visible { bool get(); void set(bool value); };
public bool Visible { get; set; }
member this.Visible : bool with get, set
Public Property Visible As Boolean

속성 값

true 컨트롤 및 해당 자식 컨트롤을 표시하려면 그렇지 않으면 입니다 false. 기본값은 true입니다. 값을 true 가져올 때 컨트롤이 표시되고 부모 컨트롤(있는 경우)이 표시되는 경우에만 반환됩니다.

예제

다음 코드 예제에서는 파생된 클래스를 VScrollBar 사용 하 HScrollBar 고 컨트롤에 표시 PictureBox 되는 의 Image 크기에 따라 해당 Visible 속성 값을 설정 합니다. 이 예제에서는 PictureBox 양식에 가 만들어졌고 HScrollBar 에 및 VScrollBar 컨트롤이 만들어졌 PictureBox어야 합니다. 이 코드는 이미지가 그림 상자에 로드될 때와 양식의 이벤트에 의해 Resize 호출되어야 합니다.

public:
   void DisplayScrollBars()
   {
      // Display or hide the scroll bars based upon  
      // whether the image is larger than the PictureBox.
      if ( pictureBox1->Width > pictureBox1->Image->Width )
      {
         hScrollBar1->Visible = false;
      }
      else
      {
         hScrollBar1->Visible = true;
      }

      if ( pictureBox1->Height > pictureBox1->Image->Height )
      {
         vScrollBar1->Visible = false;
      }
      else
      {
         vScrollBar1->Visible = true;
      }
   }
public void DisplayScrollBars()
 {
    // Display or hide the scroll bars based upon  
    // whether the image is larger than the PictureBox.
    if (pictureBox1.Width > pictureBox1.Image.Width)
    {
       hScrollBar1.Visible = false;
    }
    else
    {
       hScrollBar1.Visible = true;
    }
    
    if (pictureBox1.Height > pictureBox1.Image.Height)
    {
       vScrollBar1.Visible = false;
    }
    else
    {
       vScrollBar1.Visible = true;
    }
 }
Public Sub DisplayScrollBars()
    ' Display or hide the scroll bars based upon  
    ' whether the image is larger than the PictureBox.
    If pictureBox1.Width > pictureBox1.Image.Width Then
        hScrollBar1.Visible = False
    Else
        hScrollBar1.Visible = True
    End If
    
    If pictureBox1.Height > pictureBox1.Image.Height Then
        vScrollBar1.Visible = False
    Else
        vScrollBar1.Visible = True
    End If
End Sub

설명

를 로 true설정하는 Visible 경우

  • 컨트롤이 다른 컨트롤 뒤에 가려져 있으면 사용자에게 표시되지 않을 수 있습니다.
  • 부모 컨트롤이 표시되지 않으면 컨트롤이 표시되지 않습니다.

적용 대상

추가 정보