activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

工作流活动

上次更新日期 2026年2月20日

动态下拉列表

You can add dynamic dropdown lists in your form, using the Drop-down List component in the Form Designer. These tutorials describe how to create a dynamic dropdown list with elements that represent countries.

教程

要创建动态下拉列表,请执行以下操作:

  1. Drag and drop a Sequence activity into your workflow. For this example, name it DynamicDropdowns.
  2. 创建两个变量:
    1. 创建String变量类型,并将作用域设置为“序列”活动。在此示例中,将变量命名为country ,并将作用域设置为DynamicDropdowns
    2. 创建List<String>变量类型,并将作用域设置为“序列”活动。在此示例中,将变量命名为countryList ,并将作用域设置为DynamicDropdowns
  3. Inside the Default field of the List<String> variable, create a new List of type String, that holds the names of the countries. For example, inside the Default field of the countryList variable, type in the following expression:
    New List (Of String) From {
    "US",
    "India",
    "Romania"
    }
    New List (Of String) From {
    "US",
    "India",
    "Romania"
    }
    
  4. Drag and drop a Create Form activity in your Sequence.
  5. In the FormFieldsCollection property menu bind the variables to your form:
    1. 创建一个具有“输入/输出方向”的类型为“字符串”的参数,并将该值设置为String变量。对于此示例,将值设置为country变量。将参数命名为country
    2. 创建带有“ 输入方向”的“列表” <String>类型参数,并将值设置为 变量。List<String>对于此示例,将值设置为countryList变量。将参数命名为country_dropdown
      备注:

      country_dropdown参数使下拉列表成为动态,并使用List&lt;String&gt;变量中的元素填充该列表。

  6. Open the Form Designer.
    1. Drag and drop a Drop-down List component in the Form Designer.
    2. “字段键”选项卡中,在“属性名称”字段中输入String参数的名称。在此示例中,输入country
    3. 保存组件。
  7. 保存表单。

Result: The Drop-down List component shows as options the list of Strings created at step 3.

docs image

在数据网格中创建动态下拉列表

本教程演示如何在数据网格中创建动态下拉列表。 “数据网格”组件在表单内显示来自先前创建的数据表的数据。 要在数据网格中创建动态下拉列表,请执行以下操作:

  1. Create a Data Table using the Build Data Table activity. For this example, save the data table as a variable named sampleDataTable.

    docs image

  2. Add a Invoke Code activity into your workflow and set the Language to CSharp.

    1. 选择“编辑代码”并创建一个字符串列表,在其中添加要在下拉列表中动态显示的选项。例如,在代码编辑器中添加以下代码:

      countryListInitialized = new List<string>();
      countryListInitialized.Add("USA");
      countryListInitialized.Add("India");
      countryListInitialized.Add("Romania");
      countryListInitialized.Add("Dubai");
      countryListInitialized = new List<string>();
      countryListInitialized.Add("USA");
      countryListInitialized.Add("India");
      countryListInitialized.Add("Romania");
      countryListInitialized.Add("Dubai");
      
    2. 选择“编辑参数” ,然后创建一个参数,该参数将存储在变量中创建的字符串列表,以便稍后在工作流中使用。参数的名称必须与代码编辑器中创建的列表具有相同的名称。在此示例中,创建名为countryListInitialized 、方向为In/Out参数、类型为List<String>参数,并将值设置为List<String>变量。在此示例中,将变量命名为countryListVariable

  3. Add a Create Form activity into your workflow.

    1. 添加数据网格组件。
    2. 数据网格中添加一个文本字段组件。
    3. 数据网格中添加一个下拉列表组件 。
  4. Open the FormFieldsCollection and create the following arguments, to bind data to the form:

    名称方向类型描述
    dataGridSampleIn/Out数据表sampleDataTable此参数将“数据表”中的数据绑定到表单内的“数据网格”组件。本示例中,数据表存储在sampleDataTable变量中。
    countryList_dropdownIn/Out列表<字符串>countryListVariable此参数可将字符串列表中的数据绑定到表单内的“下拉列表” 组件。_dropdown后缀使下拉列表动态化。在此示例中,字符串列表存储在countryListVariable变量中。
    countryList_parent输入字符串"dataGridSample"该参数通过_parent后缀,并通过在“值”列中输入“数据网格”组件的“字段键”,将动态下拉列表绑定到“数据网格”组件。在此示例中, dataGridSample数据网格组件的字段键
  5. Open the Form Designer.

    1. 将“数据网格”组件的“字段键”设置为将数据表绑定到表单的参数。对于本示例,将“数据网格”组件的“字段键”设置为dataGridSample
    2. “文本字段”组件的“字段键”设置为表示文本的数据表列的名称。在此示例中,将其设置为name
    3. “下拉列表”组件的“字段键”设置为将字符串列表绑定到表单的参数名称。在此示例中,将其设置为countryList
  6. 保存每个组件和表单。

Result: The Drop-down List component shows as options the list of Strings created at step 2, inside the column of a Data Grid.

docs image

示例工作流

要查看完整的工作流或供日后参考,请下载XAML 示例

  • 教程
  • 示例工作流

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2026 UiPath。保留所有权利。