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 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
Sorry, I didn't notice the steps to reproduce, and I made a bad assumption based on the presence of an 'Ok' button. As Mike said, the problem is that the cell is not being brought out of edit mode, thus it is not updated. To this end, you probably should exit edit mode on the cell when 'Ok' is clicked (or whatever action constitutes committing the changes on the form), because if you set the new value when a new person is selected (from the ComboBox on the main form), the change made to the old one would otherwise be lost.
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,
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 Brian,
thanks for the reply but the Properties Form is not closed, thus has not been disposed. Both forms are open all the time but as soon as I select another gender with the UltraComboEditor in the UltraTree of the properties form and afterward select another person in the main form the gender combo is not updated appropriately. As soon as another control gets the focus, either by user input or programatically this problem disappears again.
Regards Wolfgang