I have a capture form for a Works order, and it has a CustomerBindingSource and WorksOrderBindingSource . Most edit fields are bound to WorksOrderBindingSource , with a ComboBox, a list of which is bound to CustomerBindingSource , and its SelectedValue bound to the CustomerId field in WorksOrderBindingSource . This is all very routine and standard, without laughter.
Then I also have text field fields in which I use to show the properties of the currently selected client for the current edited work order. I bound these fields to CustomerBindingSource . When a client is selected, these fields show the properties of that client as expected.
My problem is when I want to use a form to capture a new order of work. I create a new WorksOrder object with CustomerId == null and bind it to WorksOrderBindingSource . I do not have an object in CustomerBindingSource with Id == null , therefore, as expected, the combobox is empty, but the CustomerBindingSource.Current property points to the first Customer object in this data source. The fields associated with the client display the values โโfor this client, while the client has not yet been selected.
The only workaround for this that seems obvious to me seems awkward. In it, I have two sources of client binding, one for the selected client and filling in the clientโs display fields, and the other for filling out the drop-down list of clients. Then I need to handle the selection event, and only if the client is selected, then find this client in the binding source for the display fields, and if none is selected, set the data source for the display fields to null. It seems awfully awkward. Is there any other way to achieve what I want?
source share