Share via


DomainUpDown.DomainUpDownItemCollection-Klasse

Diese Klasse unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.

Kapselt eine Auflistung von Elementen für die Verwendung durch die DomainUpDown-Klasse.

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

Syntax

'Declaration
Public Class DomainUpDownItemCollection
    Inherits ArrayList
'Usage
Dim instance As DomainUpDownItemCollection
public class DomainUpDownItemCollection : ArrayList
public ref class DomainUpDownItemCollection : public ArrayList
public class DomainUpDownItemCollection extends ArrayList
public class DomainUpDownItemCollection extends ArrayList

Hinweise

Zum Erstellen einer Auflistung von Objekten für die Anzeige im DomainUpDown-Steuerelement können Sie die Elemente einzeln mithilfe der Add-Methode und der Remove-Methode hinzufügen bzw. entfernen. Auf die Auflistung kann mithilfe der Items-Eigenschaft aus dem übergeordneten Steuerelement, DomainUpDown, zugegriffen werden.

Beispiel

Im folgenden Beispiel wird ein DomainUpDown-Steuerelement erstellt und initialisiert. Sie können einige der Eigenschaften festlegen und eine Auflistung von Zeichenfolgen erstellen, die im Auf-Ab-Steuerelement angezeigt werden soll. Im Code wird davon ausgegangen, dass TextBox, CheckBox und Button in einem Formular instanziiert wurden. Weiterhin wird vorausgesetzt, dass auf der Klassenebene eine Membervariable als 32-Bit-Ganzzahl mit der Bezeichnung myCounter deklariert ist. Wenn Sie auf die Schaltfläche klicken, können Sie eine Zeichenfolge im Textfeld eingeben und diese der Items-Auflistung hinzufügen. Durch Klicken auf das Kontrollkästchen können Sie die Sorted-Eigenschaft aktivieren bzw. deaktivieren und im Auf-Ab-Steuerelement die Änderung der Auflistung beobachten.

Protected domainUpDown1 As DomainUpDown


Private Sub InitializeMyDomainUpDown()
    ' Create and initialize the DomainUpDown control.
    domainUpDown1 = New DomainUpDown()
    
    ' Add the DomainUpDown control to the form.
    Controls.Add(domainUpDown1)
End Sub 'InitializeMyDomainUpDown


Private Sub button1_Click(sender As Object, e As EventArgs)
    ' Add the text box contents and initial location in the collection
    ' to the DomainUpDown control.
    domainUpDown1.Items.Add((textBox1.Text.Trim() & " - " & myCounter))
    
    ' Increment the counter variable.
    myCounter = myCounter + 1
    
    ' Clear the TextBox.
    textBox1.Text = ""
End Sub 'button1_Click


Private Sub checkBox1_Click(sender As Object, e As EventArgs)
    ' If Sorted is set to true, set it to false; 
    ' otherwise set it to true.
    If domainUpDown1.Sorted Then
        domainUpDown1.Sorted = False
    Else
        domainUpDown1.Sorted = True
    End If
End Sub 'checkBox1_Click


Private Sub domainUpDown1_SelectedItemChanged _
    (sender As Object, e As EventArgs)
    
    ' Display the SelectedIndex and 
    ' SelectedItem property values in a MessageBox.
    MessageBox.Show(("SelectedIndex: " & domainUpDown1.SelectedIndex.ToString() & _
        ControlChars.Cr & "SelectedItem: " & domainUpDown1.SelectedItem.ToString()))
End Sub 'domainUpDown1_SelectedItemChanged
protected DomainUpDown domainUpDown1;

private void InitializeMyDomainUpDown()
 {
    // Create and initialize the DomainUpDown control.
    domainUpDown1 = new DomainUpDown();
    
    // Add the DomainUpDown control to the form.
    Controls.Add(domainUpDown1);
 }
 
 private void button1_Click(Object sender, 
                           EventArgs e)
 {   
    // Add the text box contents and initial location in the collection
    // to the DomainUpDown control.
    domainUpDown1.Items.Add((textBox1.Text.Trim()) + " - " + myCounter);
    
    // Increment the counter variable.
    myCounter = myCounter + 1;
 
    // Clear the TextBox.
    textBox1.Text = "";
 }
 
 private void checkBox1_Click(Object sender, 
                             EventArgs e)
 {
    // If Sorted is set to true, set it to false; 
    // otherwise set it to true.
    if (domainUpDown1.Sorted)
    {
       domainUpDown1.Sorted = false;
    }
    else
    {
       domainUpDown1.Sorted = true;
    }
 }
 
 private void domainUpDown1_SelectedItemChanged(Object sender, 
                                               EventArgs e)
 {
    // Display the SelectedIndex and 
    // SelectedItem property values in a MessageBox.
    MessageBox.Show("SelectedIndex: " + domainUpDown1.SelectedIndex.ToString() 
       + "\n" + "SelectedItem: " + domainUpDown1.SelectedItem.ToString());
 }
protected:
   DomainUpDown^ domainUpDown1;

private:
   void InitializeMyDomainUpDown()
   {
      // Create and initialize the DomainUpDown control.
      domainUpDown1 = gcnew DomainUpDown;
      
      // Add the DomainUpDown control to the form.
      Controls->Add( domainUpDown1 );
   }

   void button1_Click( Object^ sender,
      EventArgs^ e )
   {
      // Add the text box contents and initial location in the collection
      // to the DomainUpDown control.
      domainUpDown1->Items->Add( String::Concat(
         (textBox1->Text->Trim()), " - ", myCounter ) );
      
      // Increment the counter variable.
      myCounter = myCounter + 1;
      
      // Clear the TextBox.
      textBox1->Text = "";
   }

   void checkBox1_Click( Object^ sender,
      EventArgs^ e )
   {
      
      // If Sorted is set to true, set it to false; 
      // otherwise set it to true.
      domainUpDown1->Sorted =  !domainUpDown1->Sorted;
   }

   void domainUpDown1_SelectedItemChanged( Object^ sender,
      EventArgs^ e )
   {
      
      // Display the SelectedIndex and 
      // SelectedItem property values in a MessageBox.
      MessageBox::Show( String::Concat( "SelectedIndex: ", domainUpDown1->SelectedIndex,
         "\nSelectedItem: ", domainUpDown1->SelectedItem ) );
   }

Vererbungshierarchie

System.Object
   System.Collections.ArrayList
    System.Windows.Forms.DomainUpDown.DomainUpDownItemCollection

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

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

DomainUpDown.DomainUpDownItemCollection-Member
System.Windows.Forms-Namespace
DomainUpDown.Items-Eigenschaft