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

工作流活动

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

条件下拉菜单

条件下拉列表使您能够根据先前在另一个表单组件中所做的选择,从下拉列表中选择一个选项。

例如,如果您从下拉列表中选择特定州,则有条件的下拉列表将显示该州的城市。

教程

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

  1. Create a parent dropdown, by defining a workflow variable of type List<String> or Dictionary<String, String>. For example, stateList.

  2. Create a child dropdown, by defining a workflow variable of type Dictionary<String, List<String>> or Dictionary<String, Dictionary<String, String>>. For example, cityStateMap.

    docs image

  3. “调用代码”活动拖放到工作流序列中。

  4. Click Edit Arguments and add the previously created variables as In/Out arguments. Click OK.

    docs image

  5. Click Edit Code. Enter the code to initialize the data and populate the dropdowns with data. For example, the following code snippet initializes the dropdowns (stateList and cityStateMap) and adds items to them.

    // initialize the parent dropdown
    stateList = new List<string>();
    // add items to the parent dropdown
    stateList.Add("HP");
    stateList.Add("Punjab");
    // initialize the child dropdown
    cityStateMap = new Dictionary<string,List<string>>();
    // add items to the HP-child dropdown
    cityStateMap.Add("HP",new List<string>());
    cityStateMap["HP"].Add("Shimla");
    cityStateMap["HP"].Add("Solan");
    cityStateMap["HP"].Add("Hamirpur");
    // add items to the Punjab-child dropdown
    cityStateMap.Add("Punjab", new List<string>());
    cityStateMap["Punjab"].Add("Chandigarh");
    cityStateMap["Punjab"].Add("Patiala");
    cityStateMap["Punjab"].Add("Jalandhar");
    // initialize the parent dropdown
    stateList = new List<string>();
    // add items to the parent dropdown
    stateList.Add("HP");
    stateList.Add("Punjab");
    // initialize the child dropdown
    cityStateMap = new Dictionary<string,List<string>>();
    // add items to the HP-child dropdown
    cityStateMap.Add("HP",new List<string>());
    cityStateMap["HP"].Add("Shimla");
    cityStateMap["HP"].Add("Solan");
    cityStateMap["HP"].Add("Hamirpur");
    // add items to the Punjab-child dropdown
    cityStateMap.Add("Punjab", new List<string>());
    cityStateMap["Punjab"].Add("Chandigarh");
    cityStateMap["Punjab"].Add("Patiala");
    cityStateMap["Punjab"].Add("Jalandhar");
    
  6. Drag and drop the Create Form activity.

  7. 将用户下拉选择存储到工作流变量中。 例如:

    • cityListSelected,类型为 List<String>- 存储与所选状态对应的列表。
    • selectedState,属于 String类型 - 存储选定状态。
    • selectedCity,属于 String类型 - 存储所选城市。
  8. Open the FormFieldsCollection window from the activity Properties panel.

  9. 要在表单中定义下拉字段,请执行以下操作:

    • Define the dropdown fields. The Name you set is used for data binding (see Dropdown Component > Field Key tab > Property name).
    • 此外,通过将 _dropdown 附加到下拉字段名称来定义下拉列表。
  10. In the Value column, set the user selection as follows:

    • 对于父下拉列表,请使用在步骤 1 中定义的列表。
    • 对于子下拉列表,请使用在步骤 7 中存储的变量。
    • 对于父下拉字段,请使用在步骤 7 中存储的变量。
    • 对于子下拉字段,请使用在步骤 7 中存储的变量。

    docs image

  11. 单击“确定”

示例工作流

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

    此页面有帮助吗?

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