页面树结构
转至元数据结尾
转至元数据起始

可以使用Add方法以编码的方式方便的 添加项目到C1ComboBox中,或者在设计时通过String Collection Editor添加项目。如果已有多个项目,Add方法添加新项目到下一个位置。如果需要将添加项目在列表的特定位置,可以使用Insert 方法。可以使用AddRange方法将整组对象或字符串添批量加到C1ComboBox的项目列表中。
以编码的方式添加项目以编码的方式添加项目
使用C1ComboBox类的Add方法将项目添加到C1ComboBox中。集合通过Items属性引用。
Visual Basic

Visual Basic

c1ComboBox1.Items.Add("Pittsburgh")

C#

C#

c1ComboBox1.Items.Add("Pittsburgh");


通过通过String Collection Editor添加项目添加项目

  1. 在窗体上右键点击C1ComboBox控件然后选择Edit Items。出现String Collection Editor编辑器。
  2. 在String Colllection Editor编辑器中,输入字符串然后按Enter来添加下一个字符串。

在特定位置插入字符串或对象在特定位置插入字符串或对象
如下例子在第五个位置插入字符串Chicago:
Visual Basic

Visual Basic

c1ComboBox1.Items.Insert(4, "Chicago")

C#

C#

c1ComboBox1.Items.Insert(4, "Chicago");


传递一个字符串数组传递一个字符串数组
要传递一个字符串数组,完成以下步骤:

  1. 在窗体上添加一个C1ComboBox 控件。
  2. 在窗体上添加一个Button控件。
  3. 创建如下Button_Click事件处理程序并添加如下代码来传递字符串数组到C1ComboBox。

Visual Basic

Visual Basic

Type your Drop Down Section text here.

C#

C#

private void button1_Click(object sender, EventArgs e)
{
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="499e4a14-3648-4177-b3d8-cf84de10667d"><ac:plain-text-body><![CDATA[ string[] items = { "FreeStyle Stroke", "Back Stroke", "ButterFly Stroke", "Breast Stroke"}; c1ComboBox1.Items.AddRange(items);
]]></ac:plain-text-body></ac:structured-macro>
}

  1. 运行程序并点击按钮。
  2. 点击C1ComboBox控件的下拉按钮,项目中的字符串显示在下拉列表中。

  • 无标签