3

I want to have a combobox with dropdown list of codes and definitions, but only display the definition of the selected item in the textbox part. For example, Y-Yes and N-No in the dropdown, and when Y is selected, only display Yes in the textbox.

Gerry
  • 71
  • 3

1 Answers1

0

If you are using WPF to do this, use Binding.

Say you bind a collection of a class :

public class Item
{
  public string Key{
    get 
    {
      return this.Value[0].ToString();
    }
  }
  public string Value{get;set;}
  public override string ToString()
  {
     return this.Key; 
  }
}

You can use it to show Key and Value as shown

<ComboBox x:Name="cmbList" ItemsSource="{Binding}" Text="{Binding SelectedItem.Value}"></ComboBox>

I hope this would help you in solving your problem.

abhishek
  • 2,975
  • 23
  • 38