DataGridViewDataErrorEventArgs 클래스
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
DataError 이벤트에 대한 데이터를 제공합니다.
public ref class DataGridViewDataErrorEventArgs : System::Windows::Forms::DataGridViewCellCancelEventArgs
public class DataGridViewDataErrorEventArgs : System.Windows.Forms.DataGridViewCellCancelEventArgs
type DataGridViewDataErrorEventArgs = class
inherit DataGridViewCellCancelEventArgs
Public Class DataGridViewDataErrorEventArgs
Inherits DataGridViewCellCancelEventArgs
- 상속
예제
다음 코드 예제에서 제공 하는 정보에 응답 하는 방법에 설명 합니다 DataGridViewDataErrorEventArgs 클래스입니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 DataGridViewComboBoxColumn 클래스 개요 항목입니다.
private:
void DataGridView1_DataError(Object^ sender, DataGridViewDataErrorEventArgs^ anError)
{
MessageBox::Show("Error happened " + anError->Context.ToString());
if (anError->Context == DataGridViewDataErrorContexts::Commit)
{
MessageBox::Show("Commit error");
}
if (anError->Context == DataGridViewDataErrorContexts::CurrentCellChange)
{
MessageBox::Show("Cell change");
}
if (anError->Context == DataGridViewDataErrorContexts::Parsing)
{
MessageBox::Show("parsing error");
}
if (anError->Context == DataGridViewDataErrorContexts::LeaveControl)
{
MessageBox::Show("leave control error");
}
if (dynamic_cast<ConstraintException^>(anError->Exception) != nullptr)
{
DataGridView^ view = (DataGridView^)sender;
view->Rows[anError->RowIndex]->ErrorText = "an error";
view->Rows[anError->RowIndex]->Cells[anError->ColumnIndex]->ErrorText = "an error";
anError->ThrowException = false;
}
}
private void DataGridView1_DataError(object sender, DataGridViewDataErrorEventArgs anError)
{
MessageBox.Show("Error happened " + anError.Context.ToString());
if (anError.Context == DataGridViewDataErrorContexts.Commit)
{
MessageBox.Show("Commit error");
}
if (anError.Context == DataGridViewDataErrorContexts.CurrentCellChange)
{
MessageBox.Show("Cell change");
}
if (anError.Context == DataGridViewDataErrorContexts.Parsing)
{
MessageBox.Show("parsing error");
}
if (anError.Context == DataGridViewDataErrorContexts.LeaveControl)
{
MessageBox.Show("leave control error");
}
if ((anError.Exception) is ConstraintException)
{
DataGridView view = (DataGridView)sender;
view.Rows[anError.RowIndex].ErrorText = "an error";
view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an error";
anError.ThrowException = false;
}
}
Private Sub DataGridView1_DataError(ByVal sender As Object, _
ByVal e As DataGridViewDataErrorEventArgs) _
Handles DataGridView1.DataError
MessageBox.Show("Error happened " _
& e.Context.ToString())
If (e.Context = DataGridViewDataErrorContexts.Commit) _
Then
MessageBox.Show("Commit error")
End If
If (e.Context = DataGridViewDataErrorContexts _
.CurrentCellChange) Then
MessageBox.Show("Cell change")
End If
If (e.Context = DataGridViewDataErrorContexts.Parsing) _
Then
MessageBox.Show("parsing error")
End If
If (e.Context = _
DataGridViewDataErrorContexts.LeaveControl) Then
MessageBox.Show("leave control error")
End If
If (TypeOf (e.Exception) Is ConstraintException) Then
Dim view As DataGridView = CType(sender, DataGridView)
view.Rows(e.RowIndex).ErrorText = "an error"
view.Rows(e.RowIndex).Cells(e.ColumnIndex) _
.ErrorText = "an error"
e.ThrowException = False
End If
End Sub
설명
처리는 DataError 이벤트 (예를 들어, 외부 데이터 원본)에서 컨트롤 외부 코드에서 throw 된 예외를 처리할 수 있습니다. 사용 된 Context 속성의 상태를 확인 하는 DataGridView 예외 시. 사용 된 Exception 예외 데이터를 검색할 속성입니다. 추가 이벤트 처리기로 예외를 처리 하려는 경우 설정 합니다 ThrowException 속성을 true
입니다.
합니다 ColumnIndex 고 RowIndex 속성은 일반적으로 데이터 오류가 발생 한 셀을 나타냅니다. 하지만 외부 데이터 원본에서 오류가 발생, 데이터 원본을 제공할 수 없습니다 오류가 발생 한 열. 이 경우에 ColumnIndex 속성 오류 시 일반적으로 현재 셀의 열을 나타냅니다.
생성자
DataGridViewDataErrorEventArgs(Exception, Int32, Int32, DataGridViewDataErrorContexts) |
DataGridViewDataErrorEventArgs 클래스의 새 인스턴스를 초기화합니다. |
속성
Cancel |
이벤트를 취소해야 할지 여부를 나타내는 값을 가져오거나 설정합니다. (다음에서 상속됨 CancelEventArgs) |
ColumnIndex |
이벤트가 발생하는 셀의 열 인덱스를 가져옵니다. (다음에서 상속됨 DataGridViewCellCancelEventArgs) |
Context |
오류가 발생했을 때의 DataGridView 상태에 대한 세부 내용을 가져옵니다. |
Exception |
오류를 나타내는 예외를 가져옵니다. |
RowIndex |
이벤트가 발생하는 셀의 행 인덱스를 가져옵니다. (다음에서 상속됨 DataGridViewCellCancelEventArgs) |
ThrowException |
DataGridViewDataErrorEventHandler 대리자에서 처리한 예외를 throw할지 여부를 나타내는 값을 가져오거나 설정합니다. |
메서드
Equals(Object) |
지정된 개체가 현재 개체와 같은지 확인합니다. (다음에서 상속됨 Object) |
GetHashCode() |
기본 해시 함수로 작동합니다. (다음에서 상속됨 Object) |
GetType() |
현재 인스턴스의 Type을 가져옵니다. (다음에서 상속됨 Object) |
MemberwiseClone() |
현재 Object의 단순 복사본을 만듭니다. (다음에서 상속됨 Object) |
ToString() |
현재 개체를 나타내는 문자열을 반환합니다. (다음에서 상속됨 Object) |
적용 대상
추가 정보
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기