BindingManagerBase.Current Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Quando sobreposto numa classe derivada, obtém o objeto atual.
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
Valor de Propriedade
E Object que representa o objeto atual.
Exemplos
O seguinte exemplo de código imprime o valor do Current objeto em um BindingManagerBaseCurrentChanged no evento. O exemplo assume que a fonte de dados é um DataTable que contém um DataColumn nome 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
Observações
O Current objeto contém o valor do item atual na fonte de dados. Para usar o valor do item atual, deve conjurar o item para o Type do objeto contido no DataSource. Por exemplo, um DataTable contém DataRowView objetos. Para determinar o tipo do objeto atual, use os GetType métodos e ToString .
Note
Quando o DataSource é um DataSet, DataViewManager, ou DataTable, está na verdade ligado a um DataView. Consequentemente, cada Current objeto é um DataRowView objeto.