DataRow.HasErrors 属性   
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个值,该值指示某行是否包含错误。
public:
 property bool HasErrors { bool get(); };public bool HasErrors { get; }member this.HasErrors : boolPublic ReadOnly Property HasErrors As Boolean属性值
如果该行包含错误,则为 true;否则,为 false。
示例
以下示例使用 HasErrors 查找错误。 如果行有错误,该方法 GetColumnsInError 将返回列的数组,这些列具有随后可以解决的错误。 ClearErrors然后调用 方法以清除所有错误。
private void GetAllErrs(DataRow row)
{
    // Declare an array variable for DataColumn objects.
    DataColumn[] colArr;
    // If the Row has errors, check use GetColumnsInError.
    if(row.HasErrors)
    {
        // Get the array of columns in error.
        colArr = row.GetColumnsInError();
        for(int i = 0; i < colArr.Length; i++)
        {
            // Insert code to fix errors on each column.
            Console.WriteLine(colArr[i].ColumnName);
        }
        // Clear errors after reconciling.
        row.ClearErrors();
    }
}
Private Sub GetAllErrs(ByVal row As DataRow)
    ' Declare an array variable for DataColumn objects.
    Dim colArr() As DataColumn 
    ' If the Row has errors, check use GetColumnsInError.
    Dim i As Integer
    If row.HasErrors Then 
       ' Get the array of columns in error.
       colArr = row.GetColumnsInError()
       For i = 0 to colArr.Length - 1
          ' Insert code to fix errors on each column.
          Console.WriteLine(colArr(i).ColumnName)
       Next i
    ' Clear errors after reconciling.
    row.ClearErrors()
    End If
End Sub
注解
              HasErrors
              true如果DataColumn行中的任何对象包含错误,或者 的 DataRow 属性不是空字符串,则RowError返回 。
验证数据时,可以对行中的任何列设置错误。 此类列在控件中 System.Windows.Forms.DataGrid 显示时,将用红色感叹号标记,以向用户发出该列出错的信号。
使用 SetColumnError 在任何列上设置错误。
              GetColumnError使用 和 GetColumnsInError 方法返回有错误的列。
方法 ClearErrors 清除行的所有错误。