Version

Printing Data When User Selects an Item in WinOptionSet

To write code for handling changes to the WinOptionSet™, use the ValueChanged event to listen for when the user selects a new item in the set. For example, the following code would print out the index of the item and the value of the item that was just selected.

Note
Note

If no ValueList is added to the element then the DisplayText and DataValue are the same value.

In Visual Basic:

Private Sub UltraOptionSet1_ValueChanged(ByVal sender As Object, _
  ByVal e As System.EventArgs) Handles UltraOptionSet1.ValueChanged
	' This prints out the integer index of the newly selected item,
	' DisplayText, and DataValue
	MessageBox.Show(Me.UltraOptionSet1.CheckedIndex.ToString() & " " & _
	Me.UltraOptionSet1.CheckedItem.DisplayText & " " & _
	Me.UltraOptionSet1.CheckedItem.DataValue)
End Sub

In C#:

private void ultraOptionSet1_ValueChanged(object sender, EventArgs e)
{
	// This prints out the integer index of the newly selected item,
	// DisplayText, and DataValue
	MessageBox.Show(this.ultraOptionSet1.CheckedIndex.ToString() + " " +
	  this.ultraOptionSet1.CheckedItem.DisplayText + " " +
	  this.ultraOptionSet1.CheckedItem.DataValue);
}
shows how you can get the data values from the winoptionset when a value is selected