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 ImageList ab, die die im Label-Steuerelement anzuzeigenden Bilder enthält, oder legt diese fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property ImageList As ImageList
'Usage
Dim instance As Label
Dim value As ImageList
value = instance.ImageList
instance.ImageList = value
public ImageList ImageList { get; set; }
public:
property ImageList^ ImageList {
ImageList^ get ();
void set (ImageList^ value);
}
/** @property */
public ImageList get_ImageList ()
/** @property */
public void set_ImageList (ImageList value)
public function get ImageList () : ImageList
public function set ImageList (value : ImageList)
Eigenschaftenwert
Eine ImageList, in der die Auflistung von Image-Objekten gespeichert wird. Der Standardwert ist NULL (Nothing in Visual Basic).
Hinweise
Die ImageIndex-Eigenschaft und die ImageList-Eigenschaft können nicht gleichzeitig mit der Image-Eigenschaft verwendet werden. Wenn die ImageIndex-Eigenschaft und die ImageList-Eigenschaft zur Darstellung eines Bilds verwendet werden, wird die Image-Eigenschaft auf NULL (Nothing in Visual Basic) festgelegt.
Hinweis
Das Label wird nicht an den Garbage Collector übergeben, wenn noch an einer anderen Stelle auf die zugehörige ImageList verwiesen wird. Legen Sie die ImageList-Eigenschaft des Label auf NULL (Nothing in Visual Basic) fest, um eine effiziente Garbage Collection zu ermöglichen.
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
Label.Image-Eigenschaft
Label.ImageAlign-Eigenschaft
Label.ImageIndex-Eigenschaft
ImageList-Klasse