Cannot hide an error tooltip on a Datagrid, even when the errors are cleared out.

M

MAFP

Hello everybody,

When validating my datagrid, I've been using the SetColumnError method
on a row to signal an invalid value. And it works fine when my
datagrid is on my main form.

When the faulty value has been corrected, I call the ClearErrors
method and the SetColumnError again with an empty string as the
message (see CODE section at the end of the post). So the error icon
disappears from the cell but the tooltip remains.

Using the QuickWatch window of VS.NET, if I take a look at the DataRow
object after calling these 2 functions, I can see that the HasError
property is truly set to false. There is also a "hidden" field present
that is not documented: the "error" field of type DataError. This
field is an object containing the count of the number of errors and is
set to 0, which is good. But there's also an "errorList" field still
containing one element, a DataError.ColumnError element with the
message I've previously set. The same message that is still displayed
in the tooltip! It seems that the display of the icon depends on the
"HasErrors" property value while the tooltip display depends on the
elements of the "errorList". That may explain why error tooltips are
still displayed even though the errors have been cleared out.

So my question, is there a way to avoid displaying the tooltip when
there's no errors anymore?

Thanks!

MAFP


CODE:

private void ValidateDataGrid(DataColumnChangeEventArgs e)
{
if (e.Column.ColumnName == "State" &&
e.ProposedValue.GetType() == typeof(int))
{
int newValue = (int) e.ProposedValue;
if ( newValue >= 0 && newValue <= 127)
{
e.Row.ClearErrors();
e.Row.SetColumnError(e.Column, "");
}
else
{
e.Row.SetColumnError(e.Column, "Invalid Value! ");
}
}
}
 
Top