DomainUpDown.Items DomainUpDown.Items DomainUpDown.Items DomainUpDown.Items Property

Definizione

Raccolta di oggetti assegnati alla casella di selezione, denominata anche controllo di scorrimento.A collection of objects assigned to the spin box (also known as an up-down control).

public:
 property System::Windows::Forms::DomainUpDown::DomainUpDownItemCollection ^ Items { System::Windows::Forms::DomainUpDown::DomainUpDownItemCollection ^ get(); };
public System.Windows.Forms.DomainUpDown.DomainUpDownItemCollection Items { get; }
member this.Items : System.Windows.Forms.DomainUpDown.DomainUpDownItemCollection
Public ReadOnly Property Items As DomainUpDown.DomainUpDownItemCollection

Valore della proprietà

Esempi

Nell'esempio di codice seguente viene creato e DomainUpDown inizializzato un controllo.The following code example creates and initializes a DomainUpDown control. Nell'esempio è possibile impostare alcune proprietà e creare una raccolta di stringhe da visualizzare nella casella di selezione.The example allows you to set some of its properties and create a collection of strings for display in the spin box. Il codice presuppone che TextBoxsia stata creata un'istanza di, CheckBoxe Button in un form.The code assumes that a TextBox, CheckBox, and Button have been instantiated on a form. Nell'esempio si presuppone anche che sia presente una variabile membro a livello di classe dichiarata come intero con segno a myCounter32 bit denominato.The example also assumes that you have a member variable at the class level declared as a 32-bit signed integer named myCounter. È possibile immettere una stringa nella casella di testo e aggiungerla alla Items raccolta quando si fa clic sul pulsante.You can enter a string in the text box and add it to the Items collection when the button is clicked. Facendo clic sulla casella di controllo, è possibile attivare o Sorted disabilitare la proprietà e osservare la differenza nella raccolta di elementi nella casella di selezione.By clicking the check box, you can toggle the Sorted property and observe the difference in the collection of items in the spin box.

protected:
   DomainUpDown^ domainUpDown1;

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

   void button1_Click( System::Object^ sender,
     System::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.ToString() ) );
      
      // 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.
      if ( domainUpDown1->Sorted )
      {
         domainUpDown1->Sorted = false;
      }
      else
      {
         domainUpDown1->Sorted = true;
      }
   }

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

private void MySub()
 {
    // Create and initialize the DomainUpDown control.
    domainUpDown1 = new System.Windows.Forms.DomainUpDown();
    
    // Add the DomainUpDown control to the form.
    Controls.Add(domainUpDown1);
 }
 
 private void button1_Click(System.Object sender, 
                           System.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(System.Object sender, 
                             System.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(System.Object sender, 
                                               System.EventArgs e)
 {
    // Display the SelectedIndex and SelectedItem property values in a MessageBox.
    MessageBox.Show("SelectedIndex: " + domainUpDown1.SelectedIndex.ToString() 
       + "\n" + "SelectedItem: " + domainUpDown1.SelectedItem.ToString());
 }

Protected domainUpDown1 As DomainUpDown


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


Private Sub button1_Click(sender As System.Object, e As System.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 System.Object, e As System.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 System.Object, e As System.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

Commenti

La Object raccolta può essere compilata e resa disponibile DomainUpDown per il controllo in due modi.The Object collection can be built and made available to the DomainUpDown control in two ways. È possibile aggiungere elementi alla raccolta usando i Add metodi o. InsertYou can add items to the collection by using the Add or Insert methods.

Si applica a

Vedi anche