Hi iam trying to add objects into a combobox and use SelectedValue property to select and item in the combobox but it does not work, SelectedValue is still null after the assignment.
class ComboBoxItem
{
string name;
object value;
public string Name { get { return name; } }
public object Value { get { return value; } }
public ComboBoxItem(string name, object value)
{
this.name = name;
this.value = value;
}
public override bool Equals(object obj)
{
ComboBoxItem item = obj as ComboBoxItem;
return item!=null && Value.Equals(item.Value);
}
}
operatorComboBox.Items.Add(new ComboBoxItem("Gleich", SearchOperator.OpEquals));
operatorComboBox.Items.Add(new ComboBoxItem("Ungleich", SearchOperator.OpNotEquals));
operatorComboBox.ValueMember="Value";
//SelectedValue is still null after this statement
operatorComboBox.SelectedValue = SearchOperator.OpNotEquals;