简体   繁体   中英

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?

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" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM