Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft die Rahmenart des Steuerelements ab oder legt diese fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Overridable Property BorderStyle As BorderStyle
'Usage
Dim instance As Label
Dim value As BorderStyle
value = instance.BorderStyle
instance.BorderStyle = value
public virtual BorderStyle BorderStyle { get; set; }
public:
virtual property BorderStyle BorderStyle {
BorderStyle get ();
void set (BorderStyle value);
}
/** @property */
public BorderStyle get_BorderStyle ()
/** @property */
public void set_BorderStyle (BorderStyle value)
public function get BorderStyle () : BorderStyle
public function set BorderStyle (value : BorderStyle)
Eigenschaftenwert
Einer der BorderStyle-Werte. Der Standardwert ist BorderStyle.None.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der zugewiesene Wert ist keiner der BorderStyle-Werte. |
Hinweise
Mit dieser Eigenschaft können Sie dem Steuerelement einen Rahmen hinzufügen. Üblicherweise wird diese Eigenschaft zur Unterscheidung eines Label verwendet, das ein anderes Steuerelement bezeichnet, sowie eines Label, das den Status eines Vorgangs in einer Anwendung darstellt.
Beispiel
Im folgenden Beispiel wird veranschaulicht, wie mithilfe der Eigenschaften ImageList und ImageIndex ein Label-Steuerelement mit einem dreidimensionalen Rahmen und einem Bild erstellt wird. Das Steuerelement verfügt außerdem über eine Beschriftung mit einem angegebenen mnemonischen Zeichen. Im Beispielcode werden die PreferredHeight-Eigenschaft und die PreferredWidth-Eigenschaft dazu verwendet, die Größe des Label-Steuerelements in dem Formular anzupassen, auf dem es angezeigt wird. Für dieses Beispiel muss eine ImageList mit dem Namen imageList1 erstellt werden, in die zwei Bilder geladen werden. Weiterhin ist erforderlich, dass sich der Code in einem Formular befindet, in dessen Code der System.Drawing-Namespace eingebunden ist.
Public Sub CreateMyLabel()
' Create an instance of a Label.
Dim label1 As New Label()
' Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
' Set the ImageList to use for displaying an image.
label1.ImageList = imageList1
' Use the second image in imageList1.
label1.ImageIndex = 1
' Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft
' Specify that the text can display mnemonic characters.
label1.UseMnemonic = True
' Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:"
' Set the size of the control based on the PreferredHeight and PreferredWidth values.
label1.Size = New Size(label1.PreferredWidth, label1.PreferredHeight)
'...Code to add the control to the form...
End Sub
public void CreateMyLabel()
{
// Create an instance of a Label.
Label label1 = new Label();
// Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
// Set the ImageList to use for displaying an image.
label1.ImageList = imageList1;
// Use the second image in imageList1.
label1.ImageIndex = 1;
// Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft;
// Specify that the text can display mnemonic characters.
label1.UseMnemonic = true;
// Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:";
/* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
label1.Size = new Size (label1.PreferredWidth, label1.PreferredHeight);
//...Code to add the control to the form...
}
public:
void CreateMyLabel()
{
// Create an instance of a Label.
Label^ label1 = gcnew Label;
// Set the border to a three-dimensional border.
label1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
// Set the ImageList to use for displaying an image.
label1->ImageList = imageList1;
// Use the second image in imageList1.
label1->ImageIndex = 1;
// Align the image to the top left corner.
label1->ImageAlign = ContentAlignment::TopLeft;
// Specify that the text can display mnemonic characters.
label1->UseMnemonic = true;
// Set the text of the control and specify a mnemonic character.
label1->Text = "First &Name:";
/* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
label1->Size = System::Drawing::Size( label1->PreferredWidth, label1->PreferredHeight );
//...Code to add the control to the form...
}
public void CreateMyLabel()
{
// Create an instance of a Label.
Label label1 = new Label();
// Set the border to a three-dimensional border.
label1.set_BorderStyle(System.Windows.Forms.BorderStyle.Fixed3D);
// Set the ImageList to use for displaying an image.
label1.set_ImageList(imageList1);
// Use the second image in imageList1.
label1.set_ImageIndex(1);
// Align the image to the top left corner.
label1.set_ImageAlign(ContentAlignment.TopLeft);
// Specify that the text can display mnemonic characters.
label1.set_UseMnemonic(true);
// Set the text of the control and specify a mnemonic character.
label1.set_Text("First &Name:");
/* Set the size of the control based on the PreferredHeight
and PreferredWidth values. */
label1.set_Size(new Size(label1.get_PreferredWidth(),
label1.get_PreferredHeight()));
//...Code to add the control to the form...
} //CreateMyLabel
public function CreateMyLabel()
{
// Create an instance of a Label.
var label1 : Label = new Label();
// Set the border to a three-dimensional border.
label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
// Set the ImageList to use for displaying an image.
label1.ImageList = imageList1;
// Use the second image in imageList1.
label1.ImageIndex = 1;
// Align the image to the top left corner.
label1.ImageAlign = ContentAlignment.TopLeft;
// Specify that the text can display mnemonic characters.
label1.UseMnemonic = true;
// Set the text of the control and specify a mnemonic character.
label1.Text = "First &Name:";
/* Set the size of the control based on the PreferredHeight and PreferredWidth values. */
label1.Size = new System.Drawing.Size (label1.PreferredWidth, label1.PreferredHeight);
//...Code to add the control to the form...
}
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
Label-Klasse
Label-Member
System.Windows.Forms-Namespace
BorderStyle-Enumeration