The code below never sets the current cell to the error location, allowing
user to correct the mistake (see below), though does display the error
message.
This is activated when they press tab to leave the row (RowValidating) and
the next row is populated with values from DefaultValuesNeeded
I was wondering where my logic and code have failed me, instead of setting
the focus to the cell containing the error it moves to the next row with the
default values set but the error logo and text displayed?
Thanks Rob
'Validation for day of weekends
Select Case DirectCast(currentRowToValidate.Cells("bookDate").Value,
DateTime).DayOfWeek
Case DayOfWeek.Saturday Or DayOfWeek.Sunday
Me.DataGridView1.Rows(e.RowIndex).ErrorText = "Error: Booking cannot be for
the weekend, please try again."
e.Cancel = True
DataGridView1.CurrentCell = Me.DataGridView1.Item(e.ColumnIndex, e.RowIndex)
Case Else
e.Cancel = False
End Select
I also explicity tried using the column name without success (see below)
DataGridView1.CurrentCell = Me.DataGridView1.Item("bookDate", e.RowIndex)
"Rob W" <rob...@o2.co.uk> wrote in message
news:%23mmQPMv...@TK2MSFTNGP04.phx.gbl...
So no need to try and manually set the row & cell focus.
"Rob W" <rob...@o2.co.uk> wrote in message
news:ebY59WvZ...@TK2MSFTNGP06.phx.gbl...