Hi there, my problem is quite simple.
I have a ultracombo where the property:
DataSource is a data set
Datamember is a data table
Display member is bound to a field
Valuemember is bound to another field
I then bind the VALUE to a field to a separate dataTable
The datatable is populated with a long list. If I select an item from the list the Valuemember updates the field in the datatable no problem. It works.
However, if I later remove the text from the combobox, the text is not updated (not empty). I want it to be empty if the user specifies as such.
I am wondering what I am doing wrong. I hope this makes sense.
Hi,
At what point are you checking this? In other words, when are you expecting the update of the data source to occur? It does not happen on every keystroke. I think this usually only happens when you lose focus on the control or perhaps when the data source receives an EndEdit or moves to another row.
Does it work with the inbox ComboBox control?
Are you sure you data source can accept a null or empty value?
I should clarify that the control is actually a UltraComboEditor. That aside, I have 4 of them.
I check the combo boxes after they have all been set to 'blank', I set a break point and after clicking a button I inspect the datatable to find that the fields are not blank, but rather they hold the values they were before the combo was made to be empty.
I'm not sure what you mean by the 'inbox' ComboBox.
Yes I tried to hard code it:
pdsContact.ttcContact.Rows[0]["CityName"] = null; pdsContact.ttcContact.Rows[0]["CityName"] = DBNull.Value;
and it accepted it.
So the breakpoint you are referring to here is in the click event of the button? Is this an actual button or a toolbar button? I ask because toolbar buttons don't take focus, so therefore the UltraComboEditor would not lose focus.
Does it work if you type into the UltraComboEditor instead of selecting an item from the list?
By "inbox" I mean the controls that come with the DotNet framework. In this case, I was referring to the standard DotNet ComboBox control. It might help narrow down the issue if we know whether the standard control exhibits the same behavior.
My guess is that you will get the same behavior and that this is simply a quirk in how the BindingManager behaves. But if the DotNet ComboBox works differently, then it's someting we could look into further. But really, the control itself doesn't have to do much to support data binding. As long as it fires the ValueChanged event, the binding should work.
Anyway, you could try calling EndCurrentEdit on the BindingManager to commit the changes and see if that helps:
BindingManagerBase bmb = this.ultraComboEditor1.BindingContext[dataSource]; bmb.EndCurrentEdit();
BindingManagerBase bmb = this.ultraComboEditor1.BindingContext[dataSource];
bmb.EndCurrentEdit();
It is just some misculaneous .net button. There are 4 combo boxes. I empty the text (via erasing it with the keyboard) and move to the next combo (so definitely more than one combo is losing focus - causing validation).
When I press the button, I see that the text has not been removed from the associated data field.
Okay, I will see if I get similar behaviour from a DotNet combobox.