Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Im using a datagrid view.
Im validating two columns.
Min mark and Max Mark columns are validated in the way that
Minimum Mark should be greater than Maximum mark.


im displaying error text in the column.

the problem is when i enter the correct value, the error text doesnot goes until the user goes to the next cell.

its not good.

It need to be vanished when i enter the correct value.

im using the following method

Private Sub grdDisplay_CellEnter _
                            (ByVal sender As Object, _
                                    ByVal e As  _
                                 System.Windows.Forms.DataGridViewCellEventArgs) _
                                    Handles grdDisplay.CellEnter



If Val(grdDisplay.CurrentRow.Cells(2).Value) > _
                           Val(grdDisplay.CurrentRow.Cells(3).Value) Then
         grdDisplay.CurrentRow.Cells(3).ErrorText = _
         "Minimum Marks should not exceed Maximum Marks"
         Exit Sub
     Else
         grdDisplay.CurrentRow.Cells(2).ErrorText = Nothing
         grdDisplay.CurrentRow.Cells(3).ErrorText = Nothing
         grdDisplay.CurrentRow.Cells(2).ReadOnly = False
         grdDisplay.CurrentRow.Cells(3).ReadOnly = False
     End If

    End Sub



please suggest me a different method other than cellEnter
Posted
Updated 15-May-10 2:17am
v2

1 solution

How about CellValueChanged?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900