My current task is to populate a ComboBox with dates, have the user pick one and then determine which date he picked.
By default, the ComboBox control uses Object.ToString to determine what to display.
My problem is that DateTime.ToString shows both date and time. Since the time is irrelevant to my context, I don’t want it to be displayed.
Is there a way to customize what the ComboBox will display for each item? Or maybe a way to choose what DateTime.ToString will return?
In this case, I’d use the FormatString-property of the ComboBox-control:
Another possibility was the usage of
DisplayMemberandValueMemberbut I think that’s more than you need in this case.Edit: Just for completeness: There’s also a
Format-event