Sunday, May 28, 2017

SelectedText in a ComboBox isn't necessarily what it sounds like

The Windows Forms ComboBox control has, among others, properties named SelectedItem, SelectedValue, SelectedIndex, and SelectedText. It sounds like all of those refer to the entry selected in the dropdown, and that was my mistaken assumption. Actually, the last one there, SelectedText, is the text highlighted in the editable text box part of the combo-box. All the others really refer to the current drop-down choice. This seems like a good example of surprise being created by naming two different things in the same style.

No comments:

Post a Comment