Version

Display/Store Values Using ValueLists

Using ValueLists , you can display one value and store another. This example assumes your WinGrid™ is already bound to some type of data source.

To display and store a ValueList:

  1. Before you start writing any code, you should place using/imports directives in your code-behind so you don’t need to always type out a member’s fully qualified name.

In Visual Basic:

Imports Infragistics.Win

In C#:

using Infragistics.Win;
  1. Add a ValueList to the UltraGrid ValueLists collection.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.ValueLists.Add("List1")

In C#:

this.ultraGrid1.DisplayLayout.ValueLists.Add("List1");
  1. In order to show a particular value and save another value, you must work with the DataValue property as well as the DisplayText property when you add ValueListItems to the ValueList. You can pass both of these values to the Add method of the ValueListItems collection when you are populating the value list.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.ValueLists("List1").ValueListItems.Add(1, "Enterprise Support")
Me.UltraGrid1.DisplayLayout.ValueLists("List1").ValueListItems.Add(2, "No Support")
Me.UltraGrid1.DisplayLayout.ValueLists("List1").ValueListItems.Add(3, "General Support")

In C#:

this.ultraGrid1.DisplayLayout.ValueLists["List1"].ValueListItems.Add(1, "Enterprise Support");
this.ultraGrid1.DisplayLayout.ValueLists["List1"].ValueListItems.Add(2, "No Support");
this.ultraGrid1.DisplayLayout.ValueLists["List1"].ValueListItems.Add(3, "General Support");
  1. Make sure to set the display style of the ValueList so that it shows the DisplayText, and saves the DataValue.

In Visual Basic:

Me.UltraGrid1.DisplayLayout.ValueLists("List1").DisplayStyle = _
  ValueListDisplayStyle.DisplayText

In C#:

this.ultraGrid1.DisplayLayout.ValueLists["List1"].DisplayStyle =
  ValueListDisplayStyle.DisplayText;
  1. Now that the ValueList is configured, associate the ValueList with a column

In Visual Basic:

Me.UltraGrid1.DisplayLayout.Bands(0).Columns.Add("Support")
Me.UltraGrid1.DisplayLayout.Bands(0).Columns("Support").ValueList = _
  Me.UltraGrid1.DisplayLayout.ValueLists("List1")

In C#:

this.ultraGrid1.DisplayLayout.Bands[0].Columns.Add("Support");
this.ultraGrid1.DisplayLayout.Bands[0].Columns["Support"].ValueList =
  this.ultraGrid1.DisplayLayout.ValueLists["List1"];
display and store values using valuelists in ultragrid