Victor Charles
asked on
Help with forcing focus on control until data is entered propoerly.
Hi,
I'm using the code below to make sure I don't have duplicate data, problem is the user can still continue after ignoring the error message. How do I force the focus on the control when I have duplicate rows?
Private Sub C1NSN_AfterColUpdate(sende r As Object, e As C1.Win.C1TrueDBGrid.ColEve ntArgs) Handles C1NSN.AfterColUpdate
Dim col As Integer = e.ColIndex
Dim s As String
' sa = 0
s = C1NSN(C1NSN.Row, e.ColIndex).ToString()
If (s.Length < C1NSN.Columns(C1NSN.Column s.Count - 1).EditMask.Length - 3) Then
MsgBox("Data must be in following format: xxxx-xx-xxx-xxxx")
End If
If e.ColIndex = 0 Then
Dim nval As String = C1NSN.Columns(C1NSN.Col).C ellValue(C 1NSN.Row)
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS N.Col) Then
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
Exit For
End If
End If
nval = nval - 1
Next
nval = ""
End If
End Sub
Thanks,
Victor
I'm using the code below to make sure I don't have duplicate data, problem is the user can still continue after ignoring the error message. How do I force the focus on the control when I have duplicate rows?
Private Sub C1NSN_AfterColUpdate(sende
Dim col As Integer = e.ColIndex
Dim s As String
' sa = 0
s = C1NSN(C1NSN.Row, e.ColIndex).ToString()
If (s.Length < C1NSN.Columns(C1NSN.Column
MsgBox("Data must be in following format: xxxx-xx-xxx-xxxx")
End If
If e.ColIndex = 0 Then
Dim nval As String = C1NSN.Columns(C1NSN.Col).C
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
Exit For
End If
End If
nval = nval - 1
Next
nval = ""
End If
End Sub
Thanks,
Victor
ASKER
Hi,
I using the code below in BeforeColumnUpdate event to check for duplicate rows but getting error nessage:
Conversion from type 'DBNull' to type 'String' is not valid.
On line
Dim nval As String = C1NSN.Columns(C1NSN.Col).C ellValue(C 1NSN.Row)
How do I fix this error?
Private Sub C1NSN_BeforeColUpdate(send er As Object, e As C1.Win.C1TrueDBGrid.Before ColUpdateE ventArgs) Handles C1NSN.BeforeColUpdate
If e.ColIndex = 0 Then
Dim nval As String = C1NSN.Columns(C1NSN.Col).C ellValue(C 1NSN.Row)
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS N.Col) Then
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
e.Cancel = True
Exit For
End If
End If
Next
nval = ""
End If
End Sub
I using the code below in BeforeColumnUpdate event to check for duplicate rows but getting error nessage:
Conversion from type 'DBNull' to type 'String' is not valid.
On line
Dim nval As String = C1NSN.Columns(C1NSN.Col).C
How do I fix this error?
Private Sub C1NSN_BeforeColUpdate(send
If e.ColIndex = 0 Then
Dim nval As String = C1NSN.Columns(C1NSN.Col).C
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
e.Cancel = True
Exit For
End If
End If
Next
nval = ""
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi,
Thanks for the code, I tried the following approach but it did not work wne I entered duplicates (Message box with error message did not appear)
If e.ColIndex = 0 Then
If Not IsDBNull(C1NSN.Columns(C1N SN.Col).Ce llValue(C1 NSN.Row)) Then
Dim nval As String = C1NSN.Columns(C1NSN.Col).C ellValue(C 1NSN.Row)
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS N.Col) Then
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
e.Cancel = True
Exit For
End If
End If
Next
nval = ""
End If
End If
Thanks for the code, I tried the following approach but it did not work wne I entered duplicates (Message box with error message did not appear)
If e.ColIndex = 0 Then
If Not IsDBNull(C1NSN.Columns(C1N
Dim nval As String = C1NSN.Columns(C1NSN.Col).C
For r = 0 To C1NSN.RowCount - 1
If r <> C1NSN.Row Then
If nval = NSN.Tables(0).Rows(r)(C1NS
MsgBox("You entered a duplicate value. Modify data entered or slect its row and Press [Delete]")
e.Cancel = True
Exit For
End If
End If
Next
nval = ""
End If
End If
http://helpcentral.componentone.com/docs/c1truedbgrid/c1truedbgridbeforecolupdateevent.htm