I'm adding an "Index" object to each item in a Comboxbox
foreach (var index in indexes) { UniqueIndexComboBox.Items.Add(index); }
When the user selects one of the index items from the drop, the following events are both fired. I'm not sure the difference.
private void UniqueIndexComboBox_SelectedValueChanged(object sender, EventArgs e) private void UniqueIndexComboBox_SelectedIndexChanged(object sender, EventArgs e)
When I interegate the following properties, the SelectedValue is always null but I can still access the selected Index value by using the SelectedIndex value as an index into the items list.
Using a WinForm ComboBox, why would the Selected ? UniqueIndexComboBox.Items[UniqueIndexComboBox.SelectedIndex] == null false ? UniqueIndexComboBox.SelectedValue == null true
Why doesn't the SelectedValue option also work? Is the value of the DropDownStyle property relevant?
SelectedValuerequiresValueMemberproperty and populatingComboBoxwith loop won't setValueMember, you need to give indexes as datasource. - BerkaySelectedIndexproperty is the zero-based index of the currently selected item in the items list or -1 if no item is selected. It is not required to add a (database-inspired?) index to the values. See the MSDN documentation for further details. IfSelectedIndexis >= 0,UniqueIndexComboBox.Items[UniqueIndexComboBox.SelectedIndex]is always non-null, because an item IS selected.SelectedValueis used if the 'ComboBox' is data-bound. - KBO