DataRow.SetColumnError Metoda

Definicja

Ustawia opis błędu dla kolumny.

Przeciążenia

SetColumnError(DataColumn, String)

Ustawia opis błędu dla kolumny określonej jako DataColumn.

SetColumnError(Int32, String)

Ustawia opis błędu dla kolumny określonej przez indeks.

SetColumnError(String, String)

Ustawia opis błędu dla kolumny określonej przez nazwę.

SetColumnError(DataColumn, String)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Ustawia opis błędu dla kolumny określonej jako DataColumn.

public:
 void SetColumnError(System::Data::DataColumn ^ column, System::String ^ error);
public void SetColumnError (System.Data.DataColumn column, string? error);
public void SetColumnError (System.Data.DataColumn column, string error);
member this.SetColumnError : System.Data.DataColumn * string -> unit
Public Sub SetColumnError (column As DataColumn, error As String)

Parametry

column
DataColumn

Element DataColumn , aby ustawić opis błędu.

error
String

Opis błędu.

Przykłady

W poniższym przykładzie ustawiono opis błędu dla określonego DataRowelementu .

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

Uwagi

Aby sprawdzić opisy błędów, użyj GetColumnError metody .

Aby określić, czy istnieją błędy dla kolekcji kolumn, użyj HasErrors właściwości . W związku z tym można użyć GetColumnsInError metody , aby pobrać wszystkie kolumny z błędami.

Jeśli null lub pusty ciąg jest przekazywany jako error parametr, zachowuje się tak, DataRow jakby nie ustawiono błędu, a HasErrors właściwość zwróci wartość false.

Aby ustawić niestandardowy opis błędu w całym wierszu, użyj RowError właściwości .

Aby określić, czy istnieją błędy dla kolekcji kolumn, użyj HasErrors metody .

Aby wyczyścić wszystkie błędy dla kolekcji kolumn, użyj ClearErrors metody .

Zobacz też

Dotyczy

SetColumnError(Int32, String)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Ustawia opis błędu dla kolumny określonej przez indeks.

public:
 void SetColumnError(int columnIndex, System::String ^ error);
public void SetColumnError (int columnIndex, string? error);
public void SetColumnError (int columnIndex, string error);
member this.SetColumnError : int * string -> unit
Public Sub SetColumnError (columnIndex As Integer, error As String)

Parametry

columnIndex
Int32

Indeks oparty na zerze kolumny.

error
String

Opis błędu.

Wyjątki

Argument columnIndex jest poza zakresem

Przykłady

W poniższym przykładzie ustawiono opis błędu dla określonego DataRowelementu .

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

Uwagi

Metoda służy do ustawiania niestandardowych opisów błędów w określonych kolumnach. Możesz użyć kontrolki ErrorProvider , aby wyświetlić tekst błędu.

Aby sprawdzić opisy błędów, użyj GetColumnError metody .

Aby określić, czy istnieją błędy dla kolekcji kolumn, użyj HasErrors właściwości . W związku z tym można użyć GetColumnsInError metody , aby pobrać wszystkie kolumny z błędami.

Jeśli null lub pusty ciąg jest przekazywany jako error parametr, zachowuje się tak, DataRow jakby nie ustawiono błędu, a HasErrors właściwość zwróci wartość false.

Aby ustawić niestandardowy opis błędu w całym wierszu, użyj RowError właściwości .

Aby wyczyścić wszystkie błędy dla kolekcji kolumn, użyj ClearErrors metody .

Aby ustawić tekst błędu, który dotyczy całego wiersza, ustaw RowError właściwość .

Zobacz też

Dotyczy

SetColumnError(String, String)

Źródło:
DataRow.cs
Źródło:
DataRow.cs
Źródło:
DataRow.cs

Ustawia opis błędu dla kolumny określonej przez nazwę.

public:
 void SetColumnError(System::String ^ columnName, System::String ^ error);
public void SetColumnError (string columnName, string? error);
public void SetColumnError (string columnName, string error);
member this.SetColumnError : string * string -> unit
Public Sub SetColumnError (columnName As String, error As String)

Parametry

columnName
String

Nazwa kolumny.

error
String

Opis błędu.

Przykłady

W poniższym przykładzie ustawiono opis błędu dla określonego DataRowelementu .

private void SetColError(DataRow row, int columnIndex)
{
    string errorString = "Replace this text.";

    // Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString);
}

private void PrintColError(DataRow row, int columnIndex)
{
    // Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex));
}
Private Sub SetColError(ByVal row As DataRow, _
    byVal columnIndex As Integer)
    Dim errorString As String = "Replace this text."

    ' Set the error for the specified column of the row.
    row.SetColumnError(columnIndex, errorString)
End Sub
 
Private Sub PrintColError( _
    ByVal row As DataRow, byVal columnIndex As Integer)

    ' Print the error of a specified column.
    Console.WriteLine(row.GetColumnError(columnIndex))
End Sub

Uwagi

Nazwa kolumny jest ustawiana za pomocą ColumnName właściwości DataColumn klasy .

Aby sprawdzić opisy błędów, użyj GetColumnError metody .

Aby określić, czy istnieją błędy dla kolekcji kolumn, użyj HasErrors właściwości . W związku z tym można użyć GetColumnsInError metody , aby pobrać wszystkie kolumny z błędami.

Jeśli null lub pusty ciąg jest przekazywany jako error parametr, zachowuje się tak, DataRow jakby nie ustawiono błędu, a HasErrors właściwość zwróci wartość false.

Aby ustawić niestandardowy opis błędu w całym wierszu, użyj RowError właściwości .

Aby określić, czy istnieją błędy dla kolekcji kolumn, użyj HasErrors metody .

Aby wyczyścić wszystkie błędy dla kolekcji kolumn, użyj ClearErrors metody .

Zobacz też

Dotyczy