Handle data error in datagridview.
by Huy Nguyen on 11/1/2007 10:03:00 AM
Hello,
How can i force the cell to accept the input for now and flag it as error
for user to correct it later.
For Example:
case 1.
I have a column that is NOT bound to database table, then I can flag the
cell for error and move on to the next cell.
If isNumeric(DataGridView.CurrentCell.Value) = False Then
DataGridView.CurrentCell.ErrorText = "Invalid value, must be
number only"
End If
The cell will have an "!" mark on it with the error message attatched to
it.
case 2
Now, I am trying to do this with a column that bound to a database
table. And the value for this column in database is define as an Int. If I
try to enter in a non numeric value for the cell then it will call the
"dataError" event. When this happen, it will force me to stay at the current
cell until the error is fix.
Is there anyway that I can force the cell to accept the invalid value
and flag it with a "!" mark like above ?
I am sorry if I confuse you on this, and if you are, please let me know,
I'll try to explain again. Thanks
H
Re: Handle data error in datagridview.
by Cor Ligthert[MVP] on 11/2/2007 7:33:00 AM
Hyy,
You can use the errorstate of a datarow for that, then AFAIK will there be a
sign from the error provider. (I am not sure for the DataGridView however
that is the way in the DataGrid, I assume the same for the DataGridView).
Cor
Re: Handle data error in datagridview.
by Huy Nguyen on 11/2/2007 6:41:00 AM
Cor,
Thank you for getting back with me on it. However, I am not quite sure
what you mean on this. Could you please give me an example? code snippet
should be great. Thanks
"Cor Ligthert[MVP]" <notmyfirstname@planet.nl> wrote in message
news:90F4D7A0-752B-48E8-8B38-2485B5209BC0@microsoft.com...
> Hyy,
>
> You can use the errorstate of a datarow for that, then AFAIK will there be
> a sign from the error provider. (I am not sure for the DataGridView
> however that is the way in the DataGrid, I assume the same for the
> DataGridView).
>
> Cor