Freigeben über


GroupBox-Klasse

Stellt ein Windows-Steuerelement dar, dass einen Rahmen um eine Gruppe von Steuerelementen anzeigt, der eine Beschriftung enthalten kann.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
Public Class GroupBox
    Inherits Control
'Usage
Dim instance As GroupBox
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)] 
[ComVisibleAttribute(true)] 
public class GroupBox : Control
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)] 
[ComVisibleAttribute(true)] 
public ref class GroupBox : public Control
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ 
/** @attribute ComVisibleAttribute(true) */ 
public class GroupBox extends Control
ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) 
ComVisibleAttribute(true) 
public class GroupBox extends Control

Hinweise

Die GroupBox zeigt einen Rahmen um eine Gruppe von Steuerelementen an, der eine Beschriftung enthalten kann. Verwenden Sie die GroupBox, um eine Auflistung von Steuerelementen in einem Formular logisch zu gruppieren. Ein Gruppenfeld ist ein Containersteuerelement, das zum Definieren von Steuerelementgruppen verwendet werden kann.

Gruppenfelder enthalten i. d. R. eine logische Gruppe von RadioButton-Steuerelementen. Wenn Sie über zwei Gruppenfelder mit jeweils mehreren Optionsfeldern (auch als Optionsschaltflächen bezeichnet) verfügen, schließen die Schaltflächen einer Gruppe einander aus. In jeder Gruppe kann nur ein Optionswert festgelegt werden.

Mithilfe der Add-Methode der Controls-Eigenschaft können Sie GroupBox Steuerelemente hinzufügen.

Hinweis

Es können ausschließlich Steuerelemente ausgewählt werden oder den Fokus erhalten, die im GroupBox-Steuerelement enthalten sind. Die GroupBox als Ganzes kann nicht ausgewählt werden oder den Fokus erhalten. Weitere Informationen über die Reaktion dieses Steuerelements auf die Focus-Methode und die Select-Methode finden Sie unter den folgenden Control-Membern: CanFocus, CanSelect, Focused, ContainsFocus, Focus, Select.

In der GroupBox kann keine Bildlaufleiste angezeigt werden. Wenn Sie ein Steuerelement benötigen, dass einer GroupBox ähnelt, jedoch eine Bildlaufleiste enthält, finden Sie Informationen unter dem Panel-Steuerelement.

Beispiel

Im folgenden Codebeispiel werden ein GroupBox-Steuerelement und zwei RadioButton-Steuerelemente instanziiert und erstellt. Die Optionsfelder werden dem Gruppenfeld hinzugefügt, und das Gruppenfeld wird Form hinzugefügt.

Private Sub InitializeMyGroupBox()
   ' Create and initialize a GroupBox and two RadioButton controls.
   Dim groupBox1 As New GroupBox()
   Dim radioButton1 As New RadioButton()
   Dim radioButton2 As New RadioButton()

   ' Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System   
        
   ' Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1)
   groupBox1.Controls.Add(radioButton2)
        
   ' Add the GroupBox to the Form.
    Controls.Add(groupBox1)
End Sub 'InitializeMyGroupBox
private void InitializeMyGroupBox()
{
   // Create and initialize a GroupBox and two RadioButton controls.
   GroupBox groupBox1 = new GroupBox();
   RadioButton radioButton1 = new RadioButton();
   RadioButton radioButton2 = new RadioButton();

   // Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System;
 
   // Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1);
   groupBox1.Controls.Add(radioButton2);
 
   // Add the GroupBox to the Form.
   Controls.Add(groupBox1);
}
 
private:
   void InitializeMyGroupBox()
   {
      // Create and initialize a GroupBox and two RadioButton controls.
      GroupBox^ groupBox1 = gcnew GroupBox;
      RadioButton^ radioButton1 = gcnew RadioButton;
      RadioButton^ radioButton2 = gcnew RadioButton;
      
      // Add the RadioButtons to the GroupBox.
      groupBox1->Controls->Add( radioButton1 );
      groupBox1->Controls->Add( radioButton2 );
      
      // Add the GroupBox to the Form.
      Controls->Add( groupBox1 );
   }
private void InitializeMyGroupBox()
{
    // Create and initialize a GroupBox and two RadioButton controls.
    GroupBox groupBox1 = new GroupBox();
    RadioButton radioButton1 = new RadioButton();
    RadioButton radioButton2 = new RadioButton();

    // Set the FlatStyle of the GroupBox.
    groupBox1.set_FlatStyle(FlatStyle.System);

    // Add the RadioButtons to the GroupBox.
    groupBox1.get_Controls().Add(radioButton1);
    groupBox1.get_Controls().Add(radioButton2);

    // Add the GroupBox to the Form.
    get_Controls().Add(groupBox1);
} //InitializeMyGroupBox
function InitializeMyGroupBox(){
   // Create and initialize a GroupBox and two RadioButton controls.
   var groupBox1 : GroupBox = new GroupBox()
   var radioButton1 : RadioButton = new RadioButton()
   var radioButton2 : RadioButton = new RadioButton()

   // Set the FlatStyle of the GroupBox.
   groupBox1.FlatStyle = FlatStyle.System   
        
   // Add the RadioButtons to the GroupBox.
   groupBox1.Controls.Add(radioButton1)
   groupBox1.Controls.Add(radioButton2)
        
   // Add the GroupBox to the Form.
    Controls.Add(groupBox1)
}

Vererbungshierarchie

System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.Control
        System.Windows.Forms.GroupBox

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

GroupBox-Member
System.Windows.Forms-Namespace
Panel
RadioButton
ControlStyles.Selectable