I have a DataLayoutControl on a Winform bound to a bindingsource. The datasource property is set to a custom object below:
C#public class Complaint : BusinessBase<Complaint>
{
// complex object property
public WagePaymentMethod PaymentMethod
{
get { return GetProperty(paymentMethodProperty); }
set { SetProperty(paymentMethodProperty, value); }
}
One of my fields on the DataLayoutControl is set to a LookUpEdit which is bound to a different BindingSource and that datasource property on that binding source is set to a list of PaymentMethod objects so that the dropdown shows a list of payment methods (Hourly, Monthly, etc). The dropdown works and shows the description field of each PaymentMethod objects. When I select one (ex: Hourly), it places the text in the box and when I tab off of it, I get an casting error
Unable to cast object of type 'Labor.WageAndHour.BusinessLayer.WagePaymentMethod' to type 'System.String'
I have set the ValueMember property to null thinking that the binding mechanism would try to place the entire object (WagePaymentMethod) from the dropdown into the Complaint.ClaimantWagePaymentMethod property but this is not the case.
I need know how to tell your binding mechanism to assign the entire selected object in the dropdown to the the property which is a complex object so that I don't get a casting error?