Datagridview does not show warnings

Datagridview does not show warnings

Old forum URL: forums.lhotka.net/forums/t/5108.aspx


JonM posted on Wednesday, July 16, 2008

When I have a business collection bound to a grid a little red exclamation point automatically shows up next to the property if it has a broken rule with an error severity.  When I set the severity to warning it shows nothing.  Does anyone have a fix/workaround for this?  I really need to be able to show warning next to the item in the grid. 

Thanks,

Jon

rsbaker0 replied on Wednesday, July 16, 2008

I can't help you with the Datagridview, but the DevExpress XtraGrid is much more full-featured and does this just fine -- and will also show informational rules. All you have to do is have your object implement their simple IDXDataErrorInfo interface, which is straightforward given the CSLA BusinessRules implementation.

RockfordLhotka replied on Thursday, July 17, 2008

Unfortunately you must remember that the Microsoft grid (and data binding in general) only understands the concept of an error. They have no concept of warning/info messages.

So you have to address this in your UI code in some manner - by creating a custom control, using a third party control that can understand the concept, or something along that line.

JonM replied on Thursday, July 17, 2008

Okay.  Thanks for the help.  I'm actually suprised that the datagridview doesn't offer any more help in this area.

Jon

dcleven replied on Thursday, July 17, 2008

You can set the ErrorText on a cell and it will act just like a real error. Handle the CellEndEdit event and then loop through the BrokenRulesCollection you can then find your warnings and set the Cells[index].ErrorText. The error icon will show in the cell not in the row header like a real error, but it gives you the needed feedback.

Doug

Copyright (c) Marimer LLC