Irakli Lekishvili
Irakli Lekishvili

Reputation: 34158

C#, WPF ComboBox with two items inside

I have combo box which displays room numbers. Now i want to show room numbers and room types like this

102 Suite Double
305 Standard Single

and so on. I done this but problem is that i cannot get only room number. Can anyone advice me something?

Upvotes: 0

Views: 489

Answers (1)

Davide Piras
Davide Piras

Reputation: 44605

if you have two columns in the DataSource called: RoomNumberAndName and RoomNumber (id) you just need this:

<ComboBox Name="cbData" ItemsSource="{Binding DpData}"
              DisplayMemberPath="RoomNumberAndName"
              SelectedValuePath="RoomNumber" />

Upvotes: 3

Related Questions