My datasource doesn't support IDataErrorInfo, so I decided to just programmatically code for displaying the error icon through the use of ErrorProvider. I created a control derived from UltraTextEditor and added ErrorProvider to it. Standalone the error icon shows, but if I embed the control to a grid the error icon doesn't show. I just need the error icon on the actual cell I'm editing.
Any ideas? Or is there a better way to achieve what I want?
Hello,
I made small sample for you. Could you please take a look at the attached sample and video file for more details and let me know if you have any questions.
Regards
Hi,
Have you been able to resolve your issue ? Did you have a time to take a look at the attached sample. Let me know if you have any questions.
Okay, but you will still get some weird keyboard/mouse behavior, I think.
Another option you might want to consider is using the UltraValidator component. I beleive it has the ability to show an error inside a cell similar to the ErrorProvider.
I just need it in edit mode. I'm actually using an UltraTextboxEditor derived subclass with the ErrorProvider component added to it.
jquerijero said:Will the Cell.Appearance carry over to the embedded editor?
It depends on the editor. If you are using any of the built-in editors in the grid like a normal text cell, then yes. If you are using UltraControlContainerEditor, then I don't think so, but I could be wrong.
I don''t see how the ErrorProvider could show up using either editor - except for the current cell that just happens to be in edit mode at the moment. It cannot possibly display for any other cell (that is not in edit mode). And I'm sure the keyboard and mouse behavior will be weird, since you are applying the error to a control that is embedded within another control and is essentially temporary.
Will the Cell.Appearance carry over to the embedded editor?
My problem is trying to make the ErrorProvider to show up on the embedded editor for the most part. I'm not particularly worried about the cell itself since I can stop the user from committing invalid value.
So Far;
Using UltraTextEditor, it doesn't show the ErrorProvider but the click event of the control is more predictable.
Using UltraControlContainerEditor, it does show the ErrorProvider but the click event is inconsistent depending on what has been done to the activecell value..
You can't use an ErrorProvider in a cell, because the ErrorProvider needs to work with a control and the grid doesn't create a new control for each cell. Even when you use UltraTextEditor, the grid does not actually use the control itself. And with is UltraControlContainerEditor, the grid only uses one control for the cell in edit mode and one for every other cell.
It seems to me that if you just want an error image in a cell, then you could achieve this pretty easily by using the cell.Appearance.Image and maybe cell.Appearance.ImageHAlign to put the image on the right.
The only tricky part would be the tooltip. You would have to handle that yourself using MouseMove or maybe MouseEnterElement and you would have to be able to get the error information and build the tooltip text from the grid row itself.
None of this is terribly difficult. You just watch for when the mouse is over an ImageUIElement. So in MouseMove, you would use grid.DisplayLayout.UIElement.LastElementEntered. If it's an ImageUIElement, then you call GetContext and ask for the UltraGridCell. Once you have the cell, you can decide if you want a tooltip and show it using UltraToolTipManager or the inbox Tooltip component. And, of course, the cell has a reference back to the row.