Поделиться через


How to: Add Items to Windows Forms DomainUpDown Controls Programmatically

You can add items to the Windows Forms DomainUpDown control in code. Call the Add or Insert method of the DomainUpDown.DomainUpDownItemCollection class to add items to the control's Items property. The Add method adds an item to the end of a collection, while the Insert method adds an item at a specified position.

To add a new item

  1. Use the Add method to add an item to the end of the list of items.

    DomainUpDown1.Items.Add("noodles")
    
    domainUpDown1.Items.Add("noodles");
    
    domainUpDown1.get_Items().Add("noodles");
    
    domainUpDown1->Items->Add("noodles");
    

    -or-

  2. Use the Insert method to insert an item into the list at a specified position.

    ' Inserts an item at the third position in the list
    DomainUpDown1.Items.Insert(2, "rice")
    
    // Inserts an item at the third position in the list
    domainUpDown1.Items.Insert(2, "rice");
    
    // Inserts an item at the third position in the list
    domainUpDown1.get_Items().Insert(2, "rice");
    
    // Inserts an item at the third position in the list
    domainUpDown1->Items->Insert(2, "rice");
    

See Also

Reference

DomainUpDown Control Overview (Windows Forms)

DomainUpDown

DomainUpDown.DomainUpDownItemCollection.Add

ArrayList.Insert

Other Resources

DomainUpDown Control (Windows Forms)