BindingManagerBase.Current 属性

当在派生类中被重写时,获取当前对象。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public MustOverride ReadOnly Property Current As Object
用法
Dim instance As BindingManagerBase
Dim value As Object

value = instance.Current
public abstract Object Current { get; }
public:
virtual property Object^ Current {
    Object^ get () abstract;
}
/** @property */
public abstract Object get_Current ()
public abstract function get Current () : Object

属性值

代表当前对象的 Object

备注

Current 对象包含数据源中当前项的值。若要使用当前项的值,必须将该项转换为 DataSource 所包含对象的 Type。例如,DataTable 包含 DataRowView 对象。若要确定当前对象的类型,请使用 GetTypeToString 方法。

提示

DataSourceDataSetDataViewManagerDataTable 时,实际上是绑定到 DataView。因此,每个 Current 对象均为 DataRowView 对象。

示例

下面的代码示例输出 CurrentChanged 事件中的 BindingManagerBaseCurrent 对象的值。 该示例假定数据源是一个包含名为 CustNameDataColumnDataTable

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 Not bm.Current.GetType() Is 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_Changed
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();
}
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.get_Current().GetType().Equals(DataRowView.class.ToType())) {
        return;
    }
    // Otherwise, print the value of the column named "CustName".
    DataRowView drv = (DataRowView)(bm.get_Current());
    Console.Write("CurrentChanged): ");
    Console.Write(drv.get_Item("CustName"));
    Console.WriteLine();
} //Current_Changed

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

BindingManagerBase 类
BindingManagerBase 成员
System.Windows.Forms 命名空间
CurrentChanged
Position