Hello
I have a grid bound to a DataTable with only one column editable. This column uses as editor a Custom Control with combos inside, and a UltraControlContainerEditor instance is used in order to embed the custom control into a cell.
My problem is that the cells are not being updated after leaving the editor (clicking elsewhere). I am positive that the value inside the Custom Control has changed.
I have noticed that the Get method of the editing property of the custom control is being called twice after leaving the cell, returning always the last selected value (because is the same cell). I don't know if that is normal grid behaviour.
Is there any particular consideration to take into account when using the UltraControlContainerEditor with a grid bound to a DataTable?
Thanks a lot.
In order to update a cell, your EditingControl has to notify the UltraControlContainerEditor that something has changed. This will in turn notify the grid that something has changed and mark the row as edited.
There are two ways to do this.
1) Fire an event for whatever property you are using on your EditingControl. For example, if you are using the Value Property of your EditingControl (the default), then your control has to fire a ValueChanged event and time the value changes.
2) The other way to do this is to implement INotifyPropertyChanged on your control and fire off this notification any time the property you are using changes.
Thanks. The editing control property name is "Mapping", which is a String. The control has a MappingChanged event handler, which is raised accordingly when the child controls value changes. Provided this is all that is required in order the notify the ucce, I think that this should work. However, as said in my previous post, it doesn't.
Now, what I fail to understand is how the UltraControlContainerEditor is going to "catch" the raised MappingChanged event. How the ucce "knows" that this event should be "monitored"?
Any recommendations would be very appreciated.
Hi Mike
I am in the same situation described here. The Editing Control and Rendering Control are two instances of the same control. It has property called Value which is used for both editing and rendering.
I raise ValueChanged event (a public event) in the set part of Value property. However, UltraControlContainerEditor doesn't seem to be picking up the change. So when the cell loses focus the value is reset to the original value in the data source that the grid is bound to. I also tried implementing INotifyPropertyChanged on the Editing Control. But still no luck.
I have spent two days on this issue so far but failed to make any headway. Help will be much appreciated. Thanks!
Hi,
Is the EditingControlPropertyName set to Value? I think the UltraControlContainerEditor looks for a property named Value or Text, but I'm not sure in what order, so it's using the Text property instead and that's why it's not working.
Also... are you certain that when the user makes a change to your control in the UI that you are setting the Value property on that control and the ValueChanged event is actually firing?
One good way to test this is to show the RowSelectors in the grid. If you make a change to your control, the RowSelector should show a little pencil and asterisk image to show that the row is both active (the asterisk) and has pending changes (the pencil).
If you are not getting the pencil, then the grid is not detecting the change, which probably means either the event is not firing or the UltraControlContainerEditor is looking for some other event because it's using some other property.
If none of this helps, see if you can post a small sample project demonstrating the issue and I'm sure I'll be able to tell you why it's not working.
Hi Mike,
Thanks for getting back. Yes EditingControlPropertyName is set to Value. Also the event is definitely being raised because the debugger breaks into OnValueChanged method which raises the event when the value is modified. To be doubly sure I also hooked into the ValueChanged event and showed a message box in the handler. The message box popped up as expected. However, UltraControlContainerEditor doesn't seem to be hooking into the event. The row selectors don't show the pencil when value is modified.
It looks like I am missing something here. I have attached a project. Pardon my shabby code, although it should be good enough to convey the point. The grid shows batsmen (in cricket) statistics. The BattingAvg column contains a UltraControlContainerEditor which has two instances of BattingAvgControl set as Editing and Rendering controls respectively. One thing worth pointing out us that when the editing control is set to UltraTrackBar, everything works fine.
Best regards
Okash
Hi Okash,
The problem with your sample is that you created a new (unneccessary) delegate for your event. You basically declared a new delegate type for something that already exists in the DotNet Framework. ValueChanged needs to be an EventHandler.
So remove this line of code:
public delegate void ValueChangedEventHandler(object sender, EventArgs e);
and change this:
//public event ValueChangedEventHandler ValueChanged; public event EventHandler ValueChanged;
Got stung by events again! I thought it looked for any event with that name with the string "Changed" appended to it. Admittedly it doesn't make sense because the UltraControlContainerEditor would be using reflection and looking for whole signature to match.
Your help has been prompt and effective. Appreciate it!