BindingManagerBase.Current 속성

정의

파생된 클래스에서 재정의하는 경우 현재 개체를 가져옵니다.

public:
 abstract property System::Object ^ Current { System::Object ^ get(); };
public abstract object Current { get; }
public abstract object? Current { get; }
member this.Current : obj
Public MustOverride ReadOnly Property Current As Object

속성 값

현재 개체를 나타내는 Object입니다.

예제

다음 코드 예제에서는 의 개체 BindingManagerBase 값을 Current 출력 합니다 에 이벤트 CurrentChanged 입니다. 이 예제에서는 데이터 원본이 라는 CustNameDataTable 포함하는 으로 DataColumn 가정합니다.

void Current_Changed( Object^ sender, EventArgs^ /*e*/ )
{
   BindingManagerBase^ bm = dynamic_cast<BindingManagerBase^>(sender);
   
   /* Check the type of the Current object. If it is not a 
           DataRowView, exit the method. */
   if ( bm->Current->GetType() != DataRowView::typeid )
         return;

   // Otherwise, print the value of the column named "CustName".
   DataRowView^ drv = dynamic_cast<DataRowView^>(bm->Current);
   Console::Write( "CurrentChanged): " );
   Console::Write( drv[ "CustName" ] );
   Console::WriteLine();
}
private void Current_Changed(object sender, EventArgs e)
{
    BindingManagerBase bm = (BindingManagerBase) sender;
    /* Check the type of the Current object. If it is not a 
    DataRowView, exit the method. */
    if(bm.Current.GetType() != typeof(DataRowView)) return;

    // Otherwise, print the value of the column named "CustName".
    DataRowView drv = (DataRowView) bm.Current;
    Console.Write("CurrentChanged): ");
    Console.Write(drv["CustName"]);
    Console.WriteLine();
}
Private Sub Current_Changed(sender As Object, e As EventArgs)
    Dim bm As BindingManagerBase = CType(sender, BindingManagerBase)
    ' Check the type of the Current object. If it is not a
    ' DataRowView, exit the method. 
    If bm.Current.GetType() IsNot GetType(DataRowView) Then
        Return
    End If 
    ' Otherwise, print the value of the column named "CustName".
    Dim drv As DataRowView = CType(bm.Current, DataRowView)
    Console.Write("CurrentChanged): ")
    Console.Write(drv("CustName"))
    Console.WriteLine()
End Sub

설명

개체에는 Current 데이터 원본에 있는 현재 항목의 값이 포함됩니다. 현재 항목의 값을 사용하려면 에 포함된 DataSource개체의 로 항목을 Type 캐스팅해야 합니다. 예를 들어 에는 DataTable 개체가 포함됩니다 DataRowView . 현재 개체의 형식을 확인하려면 및 ToString 메서드를 GetType 사용합니다.

참고

DataSourceDataSet, DataViewManager또는 DataTable인 경우 실제로 에 바인딩 DataView됩니다. 따라서 각 Current 개체는 개체입니다 DataRowView .

적용 대상

추가 정보