如何以编程方式将项添加到 Windows 窗体 DomainUpDown 控件中

可以通过代码向 Windows 窗体DomainUpDown控件中添加项目。 调用类的AddInsert方法,将项添加到控件的Items属性。 该方法 Add 将项添加到集合的末尾,而 Insert 该方法在指定位置添加项。

添加新项

  1. Add使用该方法将项添加到项列表的末尾。

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

    -或-

  2. 使用该方法将 Insert 项插入到列表中的指定位置。

    ' 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->Items->Insert(2, "rice");
    

另请参阅