How to add your knowledge

CheckBox Control

    A check box control creates a series of check boxes positioned vertically within a group box. The data object contains an array of data items, one for each check box within the control.

    Creating a CheckBox Control

    // Create the data object of the control.
    CheckBoxData checkData = new CheckBoxData
      (this.Workflow,
      "CheckBoxKey",
      "Title", /* title of the group box */
      "MyWorkflowTest", 
      "CheckBoxKey");
    // Create the individual check box designs. Create an array of 
    // DataItems, one for each check box. The following code 
    // creates one check box.
      CheckBoxData.DataItem[] cbItems = new CheckBoxData.DataItem[1];
    // Define the specifics of a single check box. It has the
    // text "Check 1", and it is checked.
    CheckBoxData.DataItem cbItem1 = new CheckBoxData.DataItem
      ("Check 1", "Check1Tag", true);
    // Assign the newly created specifics to a place within the array.
    cbItems.SetValue(cbItem1, 0);
    // Assign the array to the data container.
    checkData.AvailableItems = cbItems;
    // Create a control containing the group box and check boxes as
    // defined in the control data object.
    CheckBoxControlDesktop checkControl = 
      new CheckBoxControlDesktop(checkData);
    // Add the control to the workflow container. 
    container.AddUserControl(checkControl);
    

    Getting User Input From CheckBox

    The status of a check box is determined by looping through all the data object data items, determining which data item represents the check box you are interested in, and testing its CheckState property.

    // Get the list of all control data objects.
    WorkflowDataList dataList = container.DataList;
    // Retrieve the check box data object from the list of
    // control data objects.
    CheckBoxData checkData = dataList["CheckBoxKey"] as CheckBoxData;
    foreach (CheckBoxData.DataItem check in checkData.CheckedItems)
    {
        if (check.CheckState == true)
        {
            // Do something if the checkbox is checked.
        }
    }