BindingManagerBase.Current Propriété

Définition

En cas de substitution dans une classe dérivée, obtient l’objet actuel.

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

Valeur de propriété

Qui Object représente l’objet actuel.

Exemples

L’exemple de code suivant imprime la valeur de l’objet Current dans un BindingManagerBase événement CurrentChanged . L’exemple suppose que la source de données est une DataTable source de données contenant un DataColumn nom CustName.

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

Remarques

L’objet Current contient la valeur de l’élément actif dans la source de données. Pour utiliser la valeur de l’élément actif, vous devez convertir l’élément en l’objet Type contenu par le DataSource. Par exemple, un DataTable objet contient DataRowView des objets. Pour déterminer le type de l’objet actuel, utilisez les méthodes et ToString les GetType méthodes.

Note

Lorsque l’objet DataSource est un DataSet, DataViewManagerou DataTable, vous êtes en fait en liaison à un DataView. Par conséquent, chaque Current objet est un DataRowView objet.

S’applique à

Voir aussi