DataGridViewCellParsingEventArgs 클래스

정의

CellParsing 컨트롤의 DataGridView 이벤트에 대한 데이터를 제공합니다.

public ref class DataGridViewCellParsingEventArgs : System::Windows::Forms::ConvertEventArgs
public class DataGridViewCellParsingEventArgs : System.Windows.Forms.ConvertEventArgs
type DataGridViewCellParsingEventArgs = class
    inherit ConvertEventArgs
Public Class DataGridViewCellParsingEventArgs
Inherits ConvertEventArgs
상속
DataGridViewCellParsingEventArgs

예제

다음 코드 예제에서는 DataGridViewCellParsingEventArgs 날짜 항목의 유효성을 검사 합니다.

// Handling CellParsing allows one to accept user input, then map it to a different
// internal representation.
void dataGridView1_CellParsing( Object^ /*sender*/, DataGridViewCellParsingEventArgs^ e )
{
   if ( this->dataGridView1->Columns[ e->ColumnIndex ]->Name->Equals( "Release Date" ) )
   {
      if ( e != nullptr )
      {
         if ( e->Value != nullptr )
         {
            try
            {
               // Map what the user typed into UTC.
               e->Value = DateTime::Parse( e->Value->ToString() ).ToUniversalTime();

               // Set the ParsingApplied property to 
               // Show the event is handled.
               e->ParsingApplied = true;
            }
            catch ( FormatException^ /*ex*/ ) 
            {
               // Set to false in case another CellParsing handler
               // wants to try to parse this DataGridViewCellParsingEventArgs instance.
               e->ParsingApplied = false;
            }
         }
      }
   }
}
// Handling CellParsing allows one to accept user input, then map it to a different
// internal representation.
private void dataGridView1_CellParsing(object sender, DataGridViewCellParsingEventArgs e)
{
    if (this.dataGridView1.Columns[e.ColumnIndex].Name == "Release Date")
    {
        if (e != null)
        {
            if (e.Value != null)
            {
                try
                {
                    // Map what the user typed into UTC.
                    e.Value = DateTime.Parse(e.Value.ToString()).ToUniversalTime();
                    // Set the ParsingApplied property to 
                    // Show the event is handled.
                    e.ParsingApplied = true;
                }
                catch (FormatException)
                {
                    // Set to false in case another CellParsing handler
                    // wants to try to parse this DataGridViewCellParsingEventArgs instance.
                    e.ParsingApplied = false;
                }
            }
        }
    }
}
' Handling CellParsing allows one to accept user input, then map it to a different
' internal representation.
Private Sub dataGridView1_CellParsing(ByVal sender As Object, _
    ByVal e As DataGridViewCellParsingEventArgs) _
    Handles dataGridView1.CellParsing

    If Me.dataGridView1.Columns(e.ColumnIndex).Name = _
        "Release Date" Then
        If e IsNot Nothing Then
            If e.Value IsNot Nothing Then
                Try
                    ' Map what the user typed into UTC.
                    e.Value = _
                    DateTime.Parse(e.Value.ToString()).ToUniversalTime()
                    ' Set the ParsingApplied property to 
                    ' Show the event is handled.
                    e.ParsingApplied = True

                Catch ex As FormatException
                    ' Set to false in case another CellParsing handler
                    ' wants to try to parse this DataGridViewCellParsingEventArgs instance.
                    e.ParsingApplied = False
                End Try
            End If
        End If
    End If
End Sub

설명

처리를 CellParsing 셀에 의해 지정 된 형식의 값으로 사용자 지정 값 변환할 사용자 지정 값을 제공 하는 이벤트 ValueType 속성입니다.

처리 하는 경우는 CellParsing 이벤트 값을 직접 변환할 수 있습니다 또는 기본 변환을 사용자 지정할 수 있습니다. 예를 들어, 변환할 수 있습니다 값 셀을 사용 하 여 직접 ParseFormattedValue 원하는 형식 변환기를 사용 하 여 메서드. 또는 기본 형식 변환기 값을 구문 분석 하지만 수정할 수는 NullValue, DataSourceNullValue, 및 FormatProvider 반환 하는 개체의 속성을 DataGridViewCellParsingEventArgs.InheritedCellStyle 셀을 사용 하 여 초기화 된 속성을 InheritedStyle 속성입니다.

초기의 서식이 지정 된 값을 바꿀 값으로 직접 변환 합니다 ConvertEventArgs.Value 속성 셀에 지정 된 형식에서 변환 된 값을 사용 하 여 ValueType 속성입니다. 더 이상 구문 분석 필요한 상태임을 나타내기 위해 설정 된 DataGridViewCellParsingEventArgs.ParsingApplied 속성을 true입니다.

완료 될 때 이벤트 처리기는 경우는 Valuenull 이거나 올바른 형식 또는 ParsingApplied 속성은 falseValue 있는 셀을 사용 하는 구문 분석 되 ParseFormattedValue 기본 형식 변환기를 사용 하 여 메서드. 이 메서드의 기본 구현을 사용 하 여 값을 구문 분석 합니다 NullValue, DataSourceNullValue, 및 FormatProvider 셀 스타일의 속성에 전달 합니다. 값 같음 없으면 NullValue, 값을 사용 하 여 구문 분석 되는 FormatProvider 속성 및 형식 변환기에 전달 합니다.

셀 값을 표시 하기 위해 형식이 지정 된 값으로 변환 사용자 지정 처리는 CellFormatting 이벤트입니다.

이벤트를 처리 하는 방법에 대 한 자세한 내용은 참조 하세요. 이벤트 처리 및 발생합니다.

생성자

DataGridViewCellParsingEventArgs(Int32, Int32, Object, Type, DataGridViewCellStyle)

DataGridViewCellParsingEventArgs 클래스의 새 인스턴스를 초기화합니다.

속성

ColumnIndex

구문 분석해야 하는 셀 데이터의 열 인덱스를 가져옵니다.

DesiredType

원하는 값의 데이터 형식을 가져옵니다.

(다음에서 상속됨 ConvertEventArgs)
InheritedCellStyle

편집된 셀에 적용되는 스타일을 가져오거나 설정합니다.

ParsingApplied

셀 값을 성공적으로 구문 분석했는지 여부를 나타내는 값을 가져오거나 설정합니다.

RowIndex

구문 분석해야 하는 셀의 행 인덱스를 가져옵니다.

Value

ConvertEventArgs의 값을 가져오거나 설정합니다.

(다음에서 상속됨 ConvertEventArgs)

메서드

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

추가 정보