Hi,
I have a problem whith the ultraGrid.I am editing a string field, and while still editing, I click outside the grid such as I gice the focus to another component.The gridLostFocus event is not raised. (If I am editing in an UltraNumericEditor it works fine).Is that a know problem, or do I do something wrong ?
Thanks
Anne-Lise
Ah, thank you.
You can just post it here if you like. Go to the Options tab to attach a zip file.
Hi Mike,
I have a small sample project to demonstrate this functionality discrepancy. How would you like me to share it with you?
In the project, you can switch which editor component is being put in the cells through the CustomGrid class. I realized that the Leave event doesn't get thrown with either editor, but the grid's lost focus event does get thrown with the UltraFormattedTextEditor. So by handling that event, I can save my edits to the data source before the button's command is executed. I have also added a handler for the toolbar button's GotFocus event (in PageView.xaml.cs) so you can verify for yourself that the button does in fact gain focus.
Tanner Stevenson said:I've already told you that the button does take focus, or else I wouldn't see the Leave event be thrown when I have an UltraFormattedTextEditor in the cell, so that explanation does not apply.
So you are saying that the Leave event of the grid fires when you are in an UltraFormattedTextEditor cell and click on the toobar button, but not when you are in a regular text cell? I have no explanation for that behavior. That's not the way it works. If you button takes focus, then the Leave event of the grid should fire. If it's a Toolbar button or some other button that doesn't take focus, then the event will not fire. The leave event is part of the DotNet framework, it's not something specific to the grid. But if that's the behavior you are getting and you can reproduce that in a small sample project, I would be happy to take a look and see what's going on.
Tanner Stevenson said:Also I'm still confused as to why any of the events of an UltraTextEditor do not get thrown such as Before/AfterEnterEditMode or GotFocus.
The events I am referring to here like Leave are events on the grid, not the editor control. If you assign an UltraTextEditor control or UltraFormattedTextEditor as the EditorComponent of a grid column, then the grid does not use that control. The control simply provides a copy of it's internal editor to the grid. So you cannot use any events on those controls (with a few rare exceptions like EditorButton events).
Tanner Stevenson said:And above all, why would the behavior of the grid be different based on the editor component in the selected cell? Shouldn't the grid be agnostic to the editor component? This is seriously one of the most frustrating aspects of this grid. The functionality details are so swept under the rug, no one seems to know why the table behaves in the way it does.
It depends what behavior you are talking about. For the most part, in most of the applications that use the grid, it's irrelevant to you, the developer, what control (or no control) is being used for editing a cell. The implementation details of the grid are not generally important. I'm still not really sure why this is giving you so much trouble, and like I said, the behavior you are describing is not something I've ever heard of before.
Tanner Stevenson said:What I mean is if I type '&', I want that character to be saved in my data source instead of '&'. I have figured out a hack way to do this, so this discussion is now probably moot.
Ah, I see. That would not work. FormattedText is xml-based and it has to use escape codes for certain characters to support formatting. If you stripped out the formatting, you would lose it the next time you ran the application. If you are not actually using any formatting and just want raw text but are using FormattedTextEditor for some other reason, then one thing you might do it hide the "real" column and add an unbound column to your grid that shows the FormattedTextEditor to the user. Then you have to handle translating between the two.
Mike Saltzman said:Well.. the Leave event will not fire unless focus leaves the grid. This will not happen in this case because you are clicking on a toolbar button and the toolbar button does not take focus. It would fire if you clicked on a regular button or some other control that takes focus.
I've already told you that the button does take focus, or else I wouldn't see the Leave event be thrown when I have an UltraFormattedTextEditor in the cell, so that explanation does not apply. Also I'm still confused as to why any of the events of an UltraTextEditor do not get thrown such as Before/AfterEnterEditMode or GotFocus. And above all, why would the behavior of the grid be different based on the editor component in the selected cell? Shouldn't the grid be agnostic to the editor component? This is seriously one of the most frustrating aspects of this grid. The functionality details are so swept under the rug, no one seems to know why the table behaves in the way it does.
Mike Saltzman said:I still do not understand what you are asking. What is a "character literal?" The grid stores whatever the Value property of the cell is.
What I mean is if I type '&', I want that character to be saved in my data source instead of '&'. I have figured out a hack way to do this, so this discussion is now probably moot. Using an UltraFormattedTextEditor I subscribed to the BeforeCellUpdate and did the following if anyone else has a similar issue:
if (e.Cell.Column.DataType == typeof(string)) { var columnProperty = e.Cell.Row.ListObject.GetType().GetProperty(e.Cell.Column.Key);
if (columnProperty != null) { columnProperty.SetValue(e.Cell.Row.ListObject, e.Cell.Text); e.Cancel = true; } }
Thanks for trying.