名前で指定した列のエラーの説明を設定します。
Overloads Public Sub SetColumnError( _
ByVal columnName As String, _ ByVal error As String _)
[C#]
public void SetColumnError(stringcolumnName,stringerror);
[C++]
public: void SetColumnError(String* columnName,String* error);
[JScript]
public function SetColumnError(
columnName : String,error : String);
パラメータ
- columnName
列の名前。 - error
エラーの説明。
解説
列の名前は、 DataColumn クラスの ColumnName プロパティを使用して設定します。
エラーの説明を調べるには、 GetColumnError メソッドを使用します。
列コレクションにエラーがあるかどうかを判断するには、 HasErrors メソッドを使用します。このため、 GetColumnsInError メソッドを使用して、エラーがあるすべての列を取得できます。
カスタム エラーの説明を行全体で設定するには、 RowError プロパティを使用します。
列コレクションにエラーがあるかどうかを判断するには、 HasErrors メソッドを使用します。
列コレクションのすべてのエラーをクリアするには、 ClearErrors メソッドを使用します。
使用例
[Visual Basic, C#, C++] 指定した DataRow にエラーの説明を設定する例を次に示します。
Private Sub SetColError(ByVal myRow As DataRow, byVal ColIndex As Integer)
Dim errorString As String
errorString = "Replace this text."
' Set the error for the specified column of the row.
myRow.SetColumnError(ColIndex, errorString)
End Sub
Private Sub PrintColError(ByVal myRow As DataRow, byVal ColIndex As Integer)
' Print the error of a specified column.
Console.WriteLine(myRow.GetColumnError(ColIndex))
End Sub
[C#]
private void SetColError(DataRow myRow, int ColIndex){
string errorString;
errorString = "Replace this text.";
// Set the error for the specified column of the row.
myRow.SetColumnError(ColIndex, errorString);
}
private void PrintColError(DataRow myRow, int ColIndex){
// Print the error of a specified column.
Console.WriteLine(myRow.GetColumnError(ColIndex));
}
[C++]
private:
void SetColError(DataRow* myRow, int ColIndex){
String* errorString;
errorString = S"Replace this text.";
// Set the error for the specified column of the row.
myRow->SetColumnError(ColIndex, errorString);
}
void PrintColError(DataRow* myRow, int ColIndex){
// Print the error of a specified column.
Console::WriteLine(myRow->GetColumnError(ColIndex));
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
DataRow クラス | DataRow メンバ | System.Data 名前空間 | DataRow.SetColumnError オーバーロードの一覧 | ClearErrors | DataColumnCollection | Contains | DataColumn | GetColumnsInError | HasErrors | RowError