DataGridView1.CurrentCell = DataGridView1.Item(1, 5)
'or
DataGridView1.CurrentCell = DataGridView1.Item("ColumnName", 5)
It would be advisable for you to find DataGridView class in documentation and browse through the members.
VB.NET:DataGridView1.CurrentCell = DataGridView1.Item(1, 5) 'or DataGridView1.CurrentCell = DataGridView1.Item("ColumnName", 5)
Dim cell As DataGridViewCell = incidentsDataGridView.Item(e.ColumnIndex, e.RowIndex)
Dim column As DataGridViewColumn = incidentsDataGridView.Columns(e.ColumnIndex)
Dim a As Object
If cell.Value.ToString.Trim & "" <> "" Then
Try
a = CType(cell.Value, Date)
Catch ex As InvalidCastException
MessageBox.Show("ETANextUpdate must be a valid date", "Row Errors on Incidents Table", MessageBoxButtons.OK, MessageBoxIcon.Error)
[B]incidentsDataGridView.Item(e.ColumnIndex, e.RowIndex).Value = ""[/B]
End Try
Else
incidentsDataGridView.CurrentCell = incidentsDataGridView.Item(e.ColumnIndex, e.RowIndex)
End If
Private Sub DataGridView1_CellValidating(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellValidatingEventArgs) _
Handles DataGridView1.CellValidating
If Not Date.TryParse(e.FormattedValue, Nothing) Then e.Cancel = True
End Sub
If Not Date.TryParse(CStr(e.FormattedValue), Nothing) Then
MessageBox.Show("Invalid date")
[B]DataGridView1.Item(e.ColumnIndex, e.RowIndex).Value = ""[/B]
e.Cancel = True
End If
DataGridView1.EditingControl.ResetText()
It would be advisable for you to find DataGridView class in documentation and browse through the members.
VB.NET:DataGridView1.CurrentCell = DataGridView1.Item(1, 5) 'or DataGridView1.CurrentCell = DataGridView1.Item("ColumnName", 5)