I have a DropDown combo box that I am trying to use to emulate functionality that MS Outlook uses when adding/editing appointments. Given an Appt.StartTime of 9:00 AM, the EndTime DropDown combo is populated with items formatted as follows:
9:00 AM (0 minutes)
9:30 AM (30 minutes)
10:00 AM (1 hour)
10:30 AM (1.5 hours)
etc.
When I select an item from that list, I would like the editable portion of the control to only show "9:30 AM" (for instance) without the additional "(30 minutes)".
In the SelectedIndexChanged event, I can temporarily succeed using the following:
String sNewTime = this.cmbEndTime.Text;
sNewTime = sNewTime.Substring(0, sNewTime.IndexOf(" ("));
cmbEndTime.Text = sNewTime;
// confirm combo-box shows only Time
MessageBox.Show("Confirm");
As soon as the MessageBox is clicked away, however, the text is re-replaced with the text in the Items collection.
Any thoughts would be greatly appreciated. Thank you.