DataRow.SetColumnError メソッド

定義

列のエラーの説明を設定します。

オーバーロード

SetColumnError(DataColumn, String)

DataColumn として指定した列のエラーの説明を設定します。

SetColumnError(Int32, String)

インデックスで指定した列のエラーの説明を設定します。

SetColumnError(String, String)

名前で指定した列のエラーの説明を設定します。

SetColumnError(DataColumn, String)

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)

パラメーター

column
DataColumn

エラーの説明を設定する対象となる DataColumn

error
String

エラーの説明。

次の例では、指定したエラーの説明を設定します DataRow

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

注釈

エラーの説明を調べるには、このメソッドを使用します GetColumnError

列コレクションにエラーが存在するかどうかを確認するには、プロパティを HasErrors 使用します。 そのため、このメソッドを GetColumnsInError 使用して、エラーのあるすべての列を取得できます。

パラメーターとしてerror空の文字列が渡された場合nullDataRowエラーが設定されていないかのように動作し、プロパティは false をHasErrors返します。

行全体にカスタム エラーの説明を設定するには、プロパティを RowError 使用します。

列コレクションにエラーが存在するかどうかを確認するには、メソッドを HasErrors 使用します。

列コレクションのすべてのエラーをクリアするには、メソッドを ClearErrors 使用します。

こちらもご覧ください

適用対象

SetColumnError(Int32, String)

インデックスで指定した列のエラーの説明を設定します。

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)

パラメーター

columnIndex
Int32

列の 0 から始まるインデックス番号。

error
String

エラーの説明。

例外

引数 columnIndex が範囲外です。

次の例では、指定したエラーの説明を設定します DataRow

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

注釈

このメソッドは、指定された列にカスタム エラーの説明を設定するために使用されます。 このコントロールを ErrorProvider 使用して、エラーのテキストを表示できます。

エラーの説明を調べるには、このメソッドを使用します GetColumnError

列コレクションにエラーが存在するかどうかを確認するには、プロパティを HasErrors 使用します。 そのため、このメソッドを GetColumnsInError 使用して、エラーのあるすべての列を取得できます。

パラメーターとしてerror空の文字列が渡された場合nullDataRowエラーが設定されていないかのように動作し、プロパティは false をHasErrors返します。

行全体にカスタム エラーの説明を設定するには、プロパティを RowError 使用します。

列コレクションのすべてのエラーをクリアするには、メソッドを ClearErrors 使用します。

行全体に適用されるエラー テキストを設定するには、プロパティを設定します RowError

こちらもご覧ください

適用対象

SetColumnError(String, String)

名前で指定した列のエラーの説明を設定します。

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)

パラメーター

columnName
String

列の名前。

error
String

エラーの説明。

次の例では、指定したエラーの説明を設定します DataRow

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

注釈

列の名前は、クラスのプロパティで ColumnName 設定されます DataColumn

エラーの説明を調べるには、このメソッドを使用します GetColumnError

列コレクションにエラーが存在するかどうかを確認するには、プロパティを HasErrors 使用します。 そのため、このメソッドを GetColumnsInError 使用して、エラーのあるすべての列を取得できます。

パラメーターとしてerror空の文字列が渡された場合nullDataRowエラーが設定されていないかのように動作し、プロパティは false をHasErrors返します。

行全体にカスタム エラーの説明を設定するには、プロパティを RowError 使用します。

列コレクションにエラーが存在するかどうかを確認するには、メソッドを HasErrors 使用します。

列コレクションのすべてのエラーをクリアするには、メソッドを ClearErrors 使用します。

こちらもご覧ください

適用対象