如何:以编程方式向 Windows 窗体 DomainUpDown 控件添加项
更新:2007 年 11 月
可以用代码向 Windows 窗体 DomainUpDown 控件添加项。调用 DomainUpDown.DomainUpDownItemCollection 类的 Add 或 Insert 方法以向控件的 Items 属性添加项。Add 方法将项添加到集合的末尾,而 Insert 方法则将项添加到指定的位置。
添加新项
使用 Add 方法将项添加到项列表的末尾。
DomainUpDown1.Items.Add("noodles")
domainUpDown1.Items.Add("noodles");
domainUpDown1.get_Items().Add("noodles");
domainUpDown1->Items->Add("noodles");
- 或 -
使用 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.get_Items().Insert(2, "rice");
// Inserts an item at the third position in the list domainUpDown1->Items->Insert(2, "rice");
请参见
参考
DomainUpDown.DomainUpDownItemCollection.Add