>[Bindable(true, BindingDirection.TwoWay), Category("User-Defined"), DefaultValue(""), Description("Payment Method") ] > public string PaymentMethod > { > get > { > return this.ddlPaymentMethod.SelectedValue; > } > set > { > if (value !="") // Here we have error if value is not in the list > this.ddlPaymentMethod.SelectedValue = value; > } > }When I try something very similar to what you have I do not get an exception if the item is not in the list.
try { string id = "3"; if (((DataSet1.DataTable1DataTable)this.comboBox2.DataSource).FindById(id)!=null) { this.comboBox2.SelectedValue = id; } else { MessageBox.Show("Not in combo"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); }I load the combo using this code:
this.comboBox2.DataSource = this.dataSet1.DataTable1; this.comboBox2.DisplayMember = "Name"; this.comboBox2.ValueMember = "Id";