Infragistics(R) NetAdvantage(R) Windows Forms
ValueMember Property
See Also  Example E-mail your feedback on this topic.
Infragistics.Win.UltraWinGrid Namespace > UltraDropDownBase Class : ValueMember Property

Determines which column (by UltraGridColumn.Key) in the dropdown is used to determine the value.

Syntax

Visual Basic (Declaration) 
Public Property ValueMember As String
C# 
public string ValueMember {get; set;}

Example

Following code initializes the ultraCombo1. It sets some of the commonly used properties of UltraCombo.

Visual BasicCopy Code
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

      Me.oleDbDataAdapter1.Fill(Me.DataSet11)

      ' Following code initializes the control.

      ' Bind the combo to a data source.
      Me.ultraCombo1.DataSource = Me.DataSet11
      Me.ultraCombo1.DataMember = ""

      ' Set the ValueMember and DisplayMember to appropriate column keys.
      Me.ultraCombo1.ValueMember = "ProductID"
      Me.ultraCombo1.DisplayMember = "ProductName"

      ' Set the border style of the edit portion by setting BorderStyle property
      ' off the UltraCombo. BorderStyle property off the DisplayLayout is for
      ' the border of the drop down window.
      Me.ultraCombo1.BorderStyle = UIElementBorderStyle.Solid
      Me.ultraCombo1.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid

      ' Turn on the auto-editing. With this turned on, the UltraCombo will
      ' automatically find a matching item as the user types in.
      Me.ultraCombo1.AutoEdit = True

      ' Set the drop down style.
      Me.ultraCombo1.DropDownStyle = UltraComboStyle.DropDown

      ' Set the appearance of the UltraCombo's edit portion.
      Me.ultraCombo1.Appearance.FontData.Bold = DefaultableBoolean.True
      Me.ultraCombo1.Appearance.ForeColor = Color.Maroon

      ' Set the appearance of the UltraCombo's drop down portion.
      Me.ultraCombo1.DisplayLayout.Appearance.ForeColor = Color.DarkBlue

      ' Set the min and max drop down items.
      Me.ultraCombo1.MinDropDownItems = 5
      Me.ultraCombo1.MaxDropDownItems = 10

  End Sub
C#Copy Code
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void Form1_Load(object sender, System.EventArgs e)
{

	this.oleDbDataAdapter1.Fill( this.dataSet11 );
	this.oleDbDataAdapter2.Fill( this.dataSet21 );
	this.oleDbDataAdapter3.Fill( this.dataSet21 );
	this.oleDbDataAdapter4.Fill( this.dataSet21 );

	// Following code initializes the control.

	// Bind the combo to a data source.
	this.ultraCombo1.DataSource = this.dataSet11;
	this.ultraCombo1.DataMember = "";

	// Set the ValueMember and DisplayMember to appropriate column keys.
	this.ultraCombo1.ValueMember   = "ProductID";
	this.ultraCombo1.DisplayMember = "ProductName";

	// Set the border style of the edit portion by setting BorderStyle property
	// off the UltraCombo. BorderStyle property off the DisplayLayout is for
	// the border of the drop down window.
	this.ultraCombo1.BorderStyle = UIElementBorderStyle.Solid;
	this.ultraCombo1.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid;
	
	// Turn on the auto-editing. With this turned on, the UltraCombo will
	// automatically find a matching item as the user types in.
	this.ultraCombo1.AutoEdit = true;

	// Set the drop down style.
	this.ultraCombo1.DropDownStyle = UltraComboStyle.DropDown;

	// Set the appearance of the UltraCombo's edit portion.
	this.ultraCombo1.Appearance.FontData.Bold = DefaultableBoolean.True;
	this.ultraCombo1.Appearance.ForeColor = Color.Maroon;

	// Set the appearance of the UltraCombo's drop down portion.
	this.ultraCombo1.DisplayLayout.Appearance.ForeColor = Color.DarkBlue;

	// Set the min and max drop down items.
	this.ultraCombo1.MinDropDownItems = 5;
	this.ultraCombo1.MaxDropDownItems = 10;

}

Remarks

The ValueMember determines which column in the dropdown is used for the value. If this property is not set, the first column will be used. To determine the column that is being used as the ValueMember, you can use the UltraDropDownBase.ValueMemberResolved property.

For example, if you have a column in an UltraGrid control where the user can drop down a list and select a customer, you would use an UltraDropDown control and bind it to a table of customers. The customer table likely has a primary key to uniquely identify customers. This customer ID field would be used as the ValueMember of the UltraDropDown.

This ID value would not be very useful to the users of the application. So you would set the Infragistics.Win.UltraWinGrid.UltraDropDownBase.DisplayMember to the field on the list that contains the customer's name. The grid cell would store the ID (probably in an integer or other numeric-type field), but the display would show the user-friendly customer name.

The UltraCombo control works the same way, except that it has it's own edit portion, instead of using a grid cell. The Infragistics.Win.UltraWinGrid.UltraCombo.Value is determined by the ValueMember and the display, and the Infragistics.Win.UltraWinGrid.UltraCombo.Text property is determined by the Infragistics.Win.UltraWinGrid.UltraDropDownBase.DisplayMember.

Infragistics.Win.UltraWinGrid.UltraDropDownBase.DisplayMember should only be set when you want to translate data values into more user-friendly display text. If you want the value stored and the value displayed on-screen to be the same, there is no need to set Infragistics.Win.UltraWinGrid.UltraDropDownBase.DisplayMember. Setting ValueMember is sufficient.

See Also