Ignore PushButtonClick event for a GridControl if all cells do not pass validation

Hi!

I have specified to some GridControl cells "CellValueType". I also have one "PushButton" cell.

If I enter invalid value in cell, I see an error message "[Entered Value] is no a valid value for [CellValueType]".

If I enter invalid value in a cell and press the "PushButton", the PusshButtonClick event is called.

How to avoid processin of PushButtonClick eventhandler, if all cells do not pass validation ?


Thanks,
Edijs

1 Reply

HA haneefm Syncfusion Team August 30, 2007 12:43 AM UTC

Hi Edijs,

One you can do this by handling the MouseDown event and call CurrentCell.Validate() method to validate PushButton cell in a Grid. Here is a code snippet that shows this task.

void gridControl1_MouseDown(object sender, MouseEventArgs e)
{
GridControl _grid = sender as GridControl;
GridCurrentCell _gCurrentCell = _grid.CurrentCell;
int _irowIndex, _icolIndex;
bool _bisInsideGrid = _grid.PointToRowCol(new Point(e.X, e.Y), out _irowIndex, out _icolIndex);
if (_bisInsideGrid && ( _gCurrentCell.RowIndex != _irowIndex || _gCurrentCell.ColIndex != _icolIndex ) )
{
if (_grid.Model[_irowIndex, _icolIndex].CellType == "PushButton")
{
_gCurrentCell.Validate();
}
}
}

Best regards,
Haneef

Loader.
Up arrow icon