rwallacej
asked on
VB.net datagridview dataerror - handle an exception
A datagridview throws System.data.nonullallowexc eption if user doesn''t enter value in field "Year"
How do I deal with this "graciously" - i.e. display a message to say "Please enter year", and jump to the "Year" field?
That's nicer than the row just getting deleted by form
Thanks
How do I deal with this "graciously" - i.e. display a message to say "Please enter year", and jump to the "Year" field?
That's nicer than the row just getting deleted by form
Thanks
ASKER
ok, I got this far with DataError
If TypeOf e.Exception Is System.Data.NoNullAllowedE xception Then
e.Cancel = True
MessageBox.Show("Period must have a value!", "PI-e2 Emissions Forecaster", MessageBoxButtons.OK, MessageBoxIcon.Exclamation )
ElseIf TypeOf e.Exception Is System.Data.ConstraintExce ption Then
e.Cancel = True
MessageBox.Show("Period must be unique!", "PI-e2 Emissions Forecaster", MessageBoxButtons.OK, MessageBoxIcon.Exclamation )
End If
HOW DO I select the Period field for user to enter period?
thanks
If TypeOf e.Exception Is System.Data.NoNullAllowedE
e.Cancel = True
MessageBox.Show("Period must have a value!", "PI-e2 Emissions Forecaster", MessageBoxButtons.OK, MessageBoxIcon.Exclamation
ElseIf TypeOf e.Exception Is System.Data.ConstraintExce
e.Cancel = True
MessageBox.Show("Period must be unique!", "PI-e2 Emissions Forecaster", MessageBoxButtons.OK, MessageBoxIcon.Exclamation
End If
HOW DO I select the Period field for user to enter period?
thanks
>>HOW DO I select the Period field for user to enter period?
Do you mean the Period cell?
Bob
Do you mean the Period cell?
Bob
ASKER
yes, I mean the period cell - sorry
ASKER
it would also be good if as well as selecting the period cell, it was automatically set to be the maximum in the Period column + 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
DataGridView1.CurrentCell = DataGridView1.Rows(DataGri dView1.Cur rentRow.In dex).Cells (0)
did it
did it
Bob