AD
Administrator
Syncfusion Team
April 11, 2005 08:55 PM UTC
Clicking on the header is setting the col header as the current cell. Then pressing the ctl-V on it is marking it as changed, and hence CurrentCellValidating is being raised for this header cell. And the code in your CurrectCellvalidating handler is trying to caste the ControlText to a single, and this is why you see the exception. The COntrolText is empty in these header cells and that leads to the exception. I do not know whether this is expected behavior or not. I will forward it to Stefan for his comments.
You can work around it easily enough by make sure your code in CurrentCellValidating is only hit when the proper cell is passed in. You can test the currend row and colindex before hitting your validation code to verify you want to validate the current cell.
If Me.grdArrearsS.CurrentCell.RowIndex > 0 AndAlso Me.grdArrearsS.CurrentCell.ColIndex > 0 Then
''....... do you validation.
You could also use double.TryParse to do the conversion and this would allow you to avoid other exceptions that might arise by trying to use CSng on an string.