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.
Asked
Active
Viewed 1,714 times
1 Answers
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
-
He doesn't mean a separate textbox. He means the textbox part. – Prince Ashitaka Oct 21 '10 at 09:34
-
Yes then it should be bound with Text property of the ComboBox. – abhishek Oct 21 '10 at 11:23