views:

194

answers:

1

When setting the source of an items control (ComboBox, for example), is it possible to have the SelectedValue property be different than the text that is displayed. I have a ComboBox that I want to display only the time portion of a DateTime, and have the value of each item be the DateTime object itself.

Thanks!

+1  A: 

The combobox has an ItemStringFormat property that dictates how items are displayed in the dropdown and textbox parts of the control.

In the case of this example from the MSDN the SelectedValue will be a datetime objects, while the control itself will display the formatted strings.

See here for how to create the format string that will work for your problem. (Something like "HH:mm:ss" I'd guess)

Martin Harris
Rawk! Thanks a bunch! ("t" works, I believe, for just getting the time).
Pwninstein