I'm not sure if this is a bug but at least it seems for me to be one.
The problem occurs in a big application but I could reduce it to a tiny sample where this occurs as well. Pls don't ask about the sense of this application since it is only mirroring the behavior of the real application.
The application consists of a main form that will be started upon application startup. In this form there is an UltraComboEditor showing persons that are taken out of a list of Person objects using databinding with a binding source. There is a second form that has an UltraTree in it which shows the person's data with an UltraTree using the OutlookExpress style so it will look like the properties view in Visual Studio. There are three properties shown for the person: first name, last name and the gender. The gender is shown using an UltraComboEditor where the value could be selected out of a list (female, male). The properties dialog hooks on the SelectionChanged event of the UltraComboEditor in the main dialog so whenever another person is selected there the properties will be shown in the UltraTree. This works all perfectly fine with one exception. As soon as I select another gender using the combo in the UltraTree and select another person in the main dialog, the gender won't update anymore. The cells for first and last name still work fine! It does update as soon as I move away the focus from the gender combo e.g. to another cell. I tried to move away the focus from that cell by programatically select the node for first name but that didn't help. I placed a button onto the properties form and in the event handler for the gender selection changed event I set the focus onto that button and this helps. It seems that there is a problem when setting the value of a cell with underlying UltraComboEditor when this cell (or the entire UltraTree) has the focus.
Although the example isn't too big I don't want to put the source code in this posting but I've attached the entire solution as a ZIP-file to this post (hope that works).
If you remove the comment in method 'OnGenderSelected' so that method Focus on the OK-Button is called this is the workaround.
Kind regards, Wolfgang
Hi Wolfgang,
If the binding just stops responding after a certain series of actions, then in my experience it usually means that an exception occurring in the binding and it was caught somewhere do you didn't see it.
Try setting the Visual Studio IDE to break on all run-time exceptions and try to reproduce the issue. I'm betting that if you do that, you will see the exception occur and that will probably give some clue about what's going wrong.
My guess is that there's a problem with the data types. The combo's value is probably returning a data type that the underlying data source cannot handle. I've also seen this same kind of thing happen if you try to write a Null into a field that does not allow nulls. The latter is probably not an issue here, since there's no null gender.
Hi Mike,
thanks for your instance reply. I've set Visual Studio to stop on all run-time exceptions as you suggested but it does not stop. I'm using data binding just on the UltraComboEditor showing the persons on the main form. The items in the gender combo on the properties form are simply added by calling comboEditor.Items.Add(...) . I'm still rather sure that is has something to do with the focus on the UltraTree cell containing the UltraComboEditor displaying the gender since it is reproducible that if the focus is moved away from that combo, it continues working. I've done this as a workaround that I always set the focus programatically onto a button on same form and then the problem does not appear so why should there be a relation to databinding?
I've also tried to have the UltraComboEditor with the persons on the same form as the tree view. This also wasn't a problem since as soon as I selected another person with that combo, the focus went away from the gender combo in the tree.
Still you are welcome to verify the problem by opening the solution from the ZIP-file attached to my original posting. I've prepared it extra for you guys :-)
Hi,
Sorry, I guess I didn't notice your sample there. I tried it out and I get the same results.
I noticed that it doesn't even matter if you select an item from the dropdown. Simply clicking on the Gender cell is enough to cause the issue. The problem is that the cell is in edit mode.
I think both Brian and I assumed that you were binding the tree. In which case, the internal code would have handled updating the value of the cell correctly. But your code is not handling the case where the cell is in edit mode. You are simply updating the Value of the cell - but this doesn't get propagated to the cell's editor.
The problem does not occur on any other cell, because none of the other cells are editable.
Anyway, to fix it, you have to do this:
if (genderValueCell.IsInEditMode) genderValueCell.EditorResolved.Value = (int)selectedPerson.Gender; else genderValueCell.Value = (int)selectedPerson.Gender;
Hi Mike and Brian,
thanks for looking at my example and for the suggested fix which works fine both in the small sample application and in the 'real' application.
Best regards, Wolfgang