vb version of cell by cell validation

  • Thread starter Thread starter jaYPee
  • Start date Start date
jaYPee said:
i have downloaded the sample of cell by cell validation from this site
http://www.syncfusion.com/faq/winforms/search/773.asp but it is a c
sharp.

anyone have a vb version of this sample program?

The ASP.NET Resource Kit contains a C# to VB converter:
(Microsoft Visual C# to VB .NET Converter)
http://msdn.microsoft.com/asp.net/asprk/

It's a little bit overkill to download 130 MB for just a 949 kB
utility, but I haven't found it available anywhere else.

There's an online conversion utility at:
http://www.kamalpatel.net/ConvertCSharp2VB.aspx
I haven't tested it yet.
 
thanks for the code. however the problem is that when i navigate to
the new row and don't enter any data and click to the other row (in
your example from any of the row from 1st row to 3rd row) it returns
an error No value at index 3.

and how can i make sure that when they add new record in this datagrid
they have to enter 1st from the 1st cell then 2nd,3rd and so on..

thanks once again..
 
Hi,

Change the DataGrid1_CurrentCellChanged procedure to this.

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DataGrid1.CurrentCellChanged
newCurrentRow = DataGrid1.CurrentCell.RowNumber
newCurrentCol = DataGrid1.CurrentCell.ColumnNumber
Dim newText As String

Try
newText = DataGrid1(oldCurrentRow, oldCurrentCol).ToString()
If newCurrentRow <> oldCurrentRow Then
Dim x As Integer

For x = 0 To 2
Dim strTemp As String = DataGrid1(oldCurrentRow,
x).ToString
If strTemp = "" Then
DataGrid1.CurrentCell = New
DataGridCell(oldCurrentRow, x)
Return
End If
Next
End If
Catch
newText = ""
End Try

If okToValidate And Not IsValidValue(oldCurrentRow, oldCurrentCol,
newText) Then
MessageBox.Show("Entry Error")
okToValidate = False
DataGrid1.CurrentCell = New DataGridCell(oldCurrentRow,
oldCurrentCol)
okToValidate = True
Else

oldCurrentRow = newCurrentRow
oldCurrentCol = newCurrentCol
End If
End Sub

Ken
-------------------
 
Thank you thank you very much for you help.

one more question and i'm done. in my datagrid i have checkbox located
in column 6. how can i prevent the user to encode to this checkbox if
the column 1 to 5 is not yet encoded?

i really really appreciate your help.

thanks once again...
 
Hi,

Try something like this

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles DataGrid1.CurrentCellChanged
newCurrentRow = DataGrid1.CurrentCell.RowNumber
newCurrentCol = DataGrid1.CurrentCell.ColumnNumber
Dim newText As String

Try
newText = DataGrid1(oldCurrentRow, oldCurrentCol).ToString()
If newCurrentRow <> oldCurrentRow Then
Dim x As Integer

For x = 0 To 2
Dim strTemp As String = DataGrid1(oldCurrentRow,
x).ToString
If strTemp = "" Then
DataGrid1.CurrentCell = New
DataGridCell(oldCurrentRow, x)
Return
End If
Next
End If
Catch
newText = ""
End Try

If newCurrentCol = 2 Then
For x As Integer = 0 To 1
Dim strTemp As String = DataGrid1(newCurrentRow, x).ToString
If strTemp = "" Then
MessageBox.Show("Please enter this value here first")
DataGrid1.CurrentCell = New DataGridCell(newCurrentRow,
x)
Return
End If
Next
End If

If okToValidate And Not IsValidValue(oldCurrentRow, oldCurrentCol,
newText) Then
MessageBox.Show("Entry Error")
okToValidate = False
DataGrid1.CurrentCell = New DataGridCell(oldCurrentRow,
oldCurrentCol)
okToValidate = True
Else
oldCurrentRow = newCurrentRow
oldCurrentCol = newCurrentCol
End If
End Sub

Ken
 
Back
Top