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

工作流活动

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

动态复选框

This is a step-by-step tutorial demonstrating how to configure and use dynamic checkboxes. Dynamic checkboxes allow you to view an entire list of data entries and select one or more, according to your use case. Dynamic checkboxes are created using the Select Boxes component in the Form Designer.

备注:

本教程演示如何仅为 C# 项目类型配置动态复选框。

教程

要使用此功能,请执行以下操作:

  1. Add an Invoke Code activity into your workflow. This is where you create a List of strings, that holds the choices that appear dynamically in the form.
    • 单击“编辑参数”并创建一个参数,在此示例中,该参数为choiceList 。将“方向”设置为In/Out ,将“类型”设置为List<String> 。在“值”字段中,按键盘上的CTRL + k并创建一个名为GchoiceListList<String>变量。此变量保存要动态显示的选项。

      docs image

    • 单击“编辑代码”并输入初始化代码片段。确保根据您选择的编程语言(C# 或 VB.NET)使用正确的语法。例如,要为choiceList参数定义四个选项,请使用以下代码:

      choiceList = new List<string>();
      choiceList.Add("Choice1");
      choiceList.Add("Choice2");
      choiceList.Add("Choice3");
      choiceList.Add("Choice4");
      choiceList = new List<string>();
      choiceList.Add("Choice1");
      choiceList.Add("Choice2");
      choiceList.Add("Choice3");
      choiceList.Add("Choice4");
      
  2. Add a Create Form activity into your workflow.
    • 打开“表单字段集合”属性窗口。

    • 创建Dictionary<String,Boolean>类型的参数。将其命名为choices ,将“方向”设置为In/Out ,将“值”设置为choices变量。此参数会将表单中的选定选项映射回工作流。

    • 创建List<String>类型的参数。将其命名为choices_selectboxes ,将“方向”设置为In/Out ,将“值”设置为GchoiceList变量。此参数通过向其添加_selectboxes后缀,从而使包含选项 ( Gchoicelist ) 的列表成为动态列表。

    • 选中生成输入字段。这使表单能够根据“表单字段集合”属性窗口中映射的参数在表单中自动生成“选择框”组件。

      docs image

      备注:

      The form determines automatically that it is dealing with a set of dynamic checkboxes and displays them accordingly.

      These checkboxes can then be later edited from the Form Designer (for example, setting the minimum or maximum choices a user can make).

  3. Add a For Each activity into your workflow. This activity iterates through every choice in the dynamic list and retrieves the name and value for each choice.
    • “类型参数”属性中,选择System.Collections.Generic.KeyValuePair<System.String,System.Boolean>
    • 在活动主体中,在“遍历循环”字段中键入keyVal
    • 在活动主体中,向“输入”字段传递choices变量。
  4. Add a Log Message activity into the Body of the For Each activity. This activity is used to output the choices selected by a user inside the form.
    • “日志级别”设置为Info

    • “消息”属性字段中,传递以下表达式: keyVal.Key +":" + keyVal.Value

      docs image

结果

The Select Boxes component is dynamically populated with the values held in the GchoiceList. For this example, a business user selects the first and second choice inside the form. When the form is submitted returns into the workflow, it displays the choices selected by the user as True and the ones that haven't been selected as False, in the Output panel.

docs image

示例工作流

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

  • 示例工作流

此页面有帮助吗?

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