Working with Value Lists

  • Updated

Prerequisites: A valid Entity and RuleSession
Namespacesxxx: InRule.Runtime, InRule.Repository
Classes: ValueListItem, RuleApplicationDef, ListItemDefCollection

Populating a combobox from a value list

// Retrieve a value list that is associated to a field
ValueList valueList = entity.Fields["State"].AssociatedValueList;

foreach (ValueListItem valueListItem in valueList)
{
  // Add the list item value to the combobox
   comboBox.Items.Add(valueListItem);
   comboBox.DisplayMemberPath = "Value";
}

Populating a combobox from a standalone value list

// Get value list using the session’s DataManager
ValueList myList = ruleSession.Data.GetValueList("StandAloneValueList");

// Tell combo box what field to display to the end user
comboBox.DisplayMemberPath = "DisplayText";

// Add the item to the combo box
foreach (ValueListItem item in myList)
{
    comboBox.Items.Add(item);             
}

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.