다음을 통해 공유


Panel 클래스

컨트롤의 컬렉션을 그룹화하는 데 사용됩니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class Panel
    Inherits ScrollableControl
‘사용 방법
Dim instance As Panel
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class Panel : ScrollableControl
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class Panel : public ScrollableControl
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class Panel extends ScrollableControl
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class Panel extends ScrollableControl

설명

Panel은 다른 컨트롤을 포함하는 컨트롤입니다. Panel을 사용하면 컨트롤의 컬렉션을 RadioButton 컨트롤 그룹과 같이 그룹화할 수 있습니다. GroupBox 컨트롤 등의 다른 Container 컨트롤과 같이 Panel 컨트롤의 Enabled 속성이 false로 설정되어 있으면 Panel에 포함된 컨트롤도 사용할 수 없게 됩니다.

기본적으로 Panel 컨트롤은 테두리 없이 표시됩니다. BorderStyle 속성을 사용하여 표준 또는 3차원 테두리를 제공하면 패널 영역을 폼의 다른 영역과 구별할 수 있습니다. Panel 컨트롤은 ScrollableControl 클래스에서 파생되므로 AutoScroll 속성을 사용하면 Panel 컨트롤에서 스크롤 막대를 활성화할 수 있습니다. AutoScroll 속성이 true로 설정되어 있으면 제공된 스크롤 막대를 사용하여 볼 수 있는 영역 외부에서 Panel 안의 모든 컨트롤을 스크롤할 수 있습니다.

Panel 컨트롤은 캡션을 표시하지 않습니다. 캡션을 표시할 수 있는 Panel과 유사한 컨트롤이 필요한 경우 GroupBox 컨트롤을 참조하십시오.

예제

다음 코드 예제에서는 Panel 컨트롤을 만들고 PanelLabelTextBox를 추가합니다. Panel 컨트롤은 3차원 테두리와 함께 표시되므로 폼에 있는 다른 개체의 위치와 Panel 컨트롤의 위치가 구별됩니다. 이 예제를 실행하려면 기존 폼 내에서 이 예제에 정의된 메서드가 호출되고 System.Drawing 네임스페이스가 폼의 소스 코드에 추가되어 있어야 합니다.

Public Sub CreateMyPanel()
    Dim panel1 As New Panel()
    Dim textBox1 As New TextBox()
    Dim label1 As New Label()
    
    ' Initialize the Panel control.
    panel1.Location = New Point(56, 72)
    panel1.Size = New Size(264, 152)
    ' Set the Borderstyle for the Panel to three-dimensional.
    panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    
    ' Initialize the Label and TextBox controls.
    label1.Location = New Point(16, 16)
    label1.Text = "label1"
    label1.Size = New Size(104, 16)
    textBox1.Location = New Point(16, 32)
    textBox1.Text = ""
    textBox1.Size = New Size(152, 20)
    
    ' Add the Panel control to the form.
    Me.Controls.Add(panel1)
    ' Add the Label and TextBox controls to the Panel.
    panel1.Controls.Add(label1)
    panel1.Controls.Add(textBox1)
End Sub
public void CreateMyPanel()
{
   Panel panel1 = new Panel();
   TextBox textBox1 = new TextBox();
   Label label1 = new Label();
   
   // Initialize the Panel control.
   panel1.Location = new Point(56,72);
   panel1.Size = new Size(264, 152);
   // Set the Borderstyle for the Panel to three-dimensional.
   panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

   // Initialize the Label and TextBox controls.
   label1.Location = new Point(16,16);
   label1.Text = "label1";
   label1.Size = new Size(104, 16);
   textBox1.Location = new Point(16,32);
   textBox1.Text = "";
   textBox1.Size = new Size(152, 20);

   // Add the Panel control to the form.
   this.Controls.Add(panel1);
   // Add the Label and TextBox controls to the Panel.
   panel1.Controls.Add(label1);
   panel1.Controls.Add(textBox1);
}
public:
   void CreateMyPanel()
   {
      Panel^ panel1 = gcnew Panel;
      TextBox^ textBox1 = gcnew TextBox;
      Label^ label1 = gcnew Label;
      
      // Initialize the Panel control.
      panel1->Location = System::Drawing::Point( 56, 72 );
      panel1->Size = System::Drawing::Size( 264, 152 );
      // Set the Borderstyle for the Panel to three-dimensional.
      panel1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
      
      // Initialize the Label and TextBox controls.
      label1->Location = System::Drawing::Point( 16, 16 );
      label1->Text = "label1";
      label1->Size = System::Drawing::Size( 104, 16 );
      textBox1->Location = System::Drawing::Point( 16, 32 );
      textBox1->Text = "";
      textBox1->Size = System::Drawing::Size( 152, 20 );
      
      // Add the Panel control to the form.
      this->Controls->Add( panel1 );
      // Add the Label and TextBox controls to the Panel.
      panel1->Controls->Add( label1 );
      panel1->Controls->Add( textBox1 );
   }
public void CreateMyPanel()
{
    Panel panel1 = new Panel();
    TextBox textBox1 = new TextBox();
    Label label1 = new Label();

    // Initialize the Panel control.
    panel1.set_Location(new Point(56, 72));
    panel1.set_Size(new Size(264, 152));

    // Set the Borderstyle for the Panel to three-dimensional.
    panel1.set_BorderStyle(System.Windows.Forms.BorderStyle.Fixed3D);

    // Initialize the Label and TextBox controls.
    label1.set_Location(new Point(16, 16));
    label1.set_Text("label1");
    label1.set_Size(new Size(104, 16));
    textBox1.set_Location(new Point(16, 32));
    textBox1.set_Text("");
    textBox1.set_Size(new Size(152, 20));

    // Add the Panel control to the form.
    this.get_Controls().Add(panel1);

    // Add the Label and TextBox controls to the Panel.
    panel1.get_Controls().Add(label1);
    panel1.get_Controls().Add(textBox1);
} //CreateMyPanel

상속 계층 구조

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
         System.Windows.Forms.ScrollableControl
          System.Windows.Forms.Panel
             파생 클래스

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Panel 멤버
System.Windows.Forms 네임스페이스
GroupBox 클래스