DataRow.HasErrors Özellik

Tanım

Satırda hata olup olmadığını belirten bir değer alır.

public:
 property bool HasErrors { bool get(); };
public bool HasErrors { get; }
member this.HasErrors : bool
Public ReadOnly Property HasErrors As Boolean

Özellik Değeri

true satırda hata varsa; aksi takdirde , false.

Örnekler

Aşağıdaki örnek, hataları aramak için öğesini HasErrors kullanır. Satırda hatalar varsa yöntemi, GetColumnsInError düzeltilebilen hata içeren sütun dizisini döndürür. Ardından ClearErrors tüm hataları temizlemek için yöntemi çağrılır.

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

Açıklamalar

HasErrorssatırdaki herhangi bir DataColumn nesne hata içeriyorsa veya özelliğinin DataRowRowError boş bir dize olmaması durumunda döndürürtrue.

Verileri doğrularken, satırdaki herhangi bir sütunda hata ayarlayabilirsiniz. Denetimde görüntülenen böyle bir sütun, kullanıcıya sütunun System.Windows.Forms.DataGrid hatalı olduğunu belirten kırmızı bir ünlem işaretiyle işaretlenir.

Herhangi bir sütunda hata ayarlamak için kullanın SetColumnError .

Hataları olan GetColumnError sütunları döndürmek için ve GetColumnsInError yöntemlerini kullanın.

ClearErrors yöntemi, satır için tüm hataları temizler.

Şunlara uygulanır

Ayrıca bkz.