Versión imprimible       Enviar     
Evaluar y enviar comentarios

  Encender vista de ancho de banda bajo
Esta página es específica de
Microsoft Visual Studio 2005/.NET Framework 2.0

Hay además otras versiones disponibles para:
Panel (Clase)
Utilizado para agrupar colecciones de controles.

Espacio de nombres: System.Windows.Forms
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)

Visual Basic (Declaración)
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class Panel
    Inherits ScrollableControl
Visual Basic (Uso)
Dim instance As Panel
C#
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class Panel : ScrollableControl
C++
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class Panel : public ScrollableControl
J#
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class Panel extends ScrollableControl
JScript
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class Panel extends ScrollableControl
XAML
No aplicable.

Panel es un control que contiene otros controles. Se puede utilizar Panel para agrupar colecciones de controles, como un grupo de controles RadioButton. Al igual que sucede con otros controles contenedores, como el control GroupBox, si la propiedad Enabled del control Panel está establecida en false, los controles contenidos dentro de Panel también se deshabilitarán.

El control Panel se muestra de forma predeterminada sin bordes. Para proporcionar un borde estándar o tridimensional, se utiliza la propiedad BorderStyle para distinguir el área del panel de otras áreas del formulario. Debido a que el control Panel deriva de la clase ScrollableControl, se puede utilizar la propiedad AutoScroll para habilitar barras de desplazamiento en el control Panel. Cuando la propiedad AutoScroll está establecida en true, es posible desplazarse a cualquier control situado dentro de Panel, aunque fuera de su región visible, con las barras de desplazamiento proporcionadas.

El control Panel no muestra ningún título. Si necesita un control similar a Panel que puede mostrar un título, vea el control GroupBox.

En el ejemplo de código siguiente se crea un control Panel, y se agrega Label y TextBox a Panel. El control Panel se muestra con un borde tridimensional para distinguir dónde está situado el control Panel en relación con otros objetos del formulario. En este ejemplo se requiere que se llame al método definido en este ejemplo desde dentro de un formulario existente y que se haya agregado el espacio de nombres System.Drawing al código fuente para el formulario.

Visual Basic
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

C#
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);
}

C++
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 );
   }
J#
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
             Clases derivadas
Los miembros estáticos públicos (Shared en Visual Basic) de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.

Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter

Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

.NET Framework

Compatible con: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Compatible con: 2.0, 1.0
© 2009 Microsoft Corporation. Reservados todos los derechos. Términos de uso  |  Marcas Registradas  |  Privacidad
Page view tracker