Home Forums WinForms controls Xceed Grid for WinForms Exception on collapse Reply To: Exception on collapse

User (Old forums)
Member
Post count: 23064

Hello again,

It seems there is a bug in Xceed’s code. If a detail grid collapse changing attend is performed when a cell in that detail grid is not validated, the GridValidationException which is thrown by the CellEditorManagerCore.EndEdit(boolean) is not swallowed by the Xceed code. More specifically, I think it has to be swallowed somewhere in the Collapse() method or Collapse setter.

 The MasterGrid.SelectWithMouse() method does this swallowing of this exception (that’s why when clicking somewhere else in the grid and a cell is not yet validated, this exception is not causing the app to crash), but in case of a collapse when a cell is not yet validated, this method is not called, so the GridValidationException is propagated and the app crashes.

The workaround I found is to swallow this exception in the OnClick and OnDoubleClick methods of the parent grid control ()(the last one can cause too a collapse):

        protected override void OnClick(EventArgs e)
        {
            //if a click is performed on the +- glyph, the GridValidationException (if raised)
            //is not swallowed in Xceed code (as it should)
            try
            {
                base.OnClick(e);
            }
            catch (GridValidationException) { }
        }

        protected override void OnDoubleClick(EventArgs e)
        {
            //if a double click on a row that produce a collapse state changing is made,
            //the GridValidationException (if raised) is not swallowed in Xceed code (as it should)
            try
            {
                base.OnDoubleClick(e);
            }
            catch (Exception ex)
            {
                if (!(ex is GridValidationException || ex.InnerException is GridValidationException))
                    throw;
            }
        }

And it works, now if I try to collapse a detail grid which has a cell not yet validated (and with an error description attached), I can not, and the cell is left in edit mode, with the error icon displayed, as it should.

Anyways, if Xceed team would have answered to this issue, they would have freed us from a lot of head aches and wasted time in “reflectoring” and studying their code to find up what’s happening.  

Imported from legacy forums. Posted by bogdip (had 1713 views)