BindingSource.Current Property

Gets the current item in the list.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

<BrowsableAttribute(False)> _
Public ReadOnly Property Current As Object

Property Value

Type: System.Object
An Object that represents the current item in the underlying list represented by the List property, or Nothing if the list has no items.

Use the Current property to access the current item, but use the List property to get the entire list. To determine the type of the current object, use the GetType, or ToString methods.

To change the current item, set the Position property to a new integral value, or use one of the navigation methods such as MoveNext.

The following code example demonstrates the Current property. To run this example, paste the code into a form and call the PopulateBindingSourceWithFonts method from the form's Load event handling method.

Private WithEvents bindingSource1 As New BindingSource()
Private box1 As New TextBox()

Private Sub PopulateBindingSourceWithFonts()

    bindingSource1.Add(New Font(FontFamily.Families(2), 8.0F))
    bindingSource1.Add(New Font(FontFamily.Families(4), 9.0F))
    bindingSource1.Add(New Font(FontFamily.Families(6), 10.0F))
    bindingSource1.Add(New Font(FontFamily.Families(8), 11.0F))
    bindingSource1.Add(New Font(FontFamily.Families(10), 12.0F))
    Dim view1 As New DataGridView()
    view1.DataSource = bindingSource1
    view1.AutoGenerateColumns = True
    view1.Dock = DockStyle.Top
    box1.Dock = DockStyle.Bottom
    box1.Text = "Sample Text" 
    view1.Columns("Name").DisplayIndex = 0
    box1.DataBindings.Add("Text", bindingSource1, "Name")

End Sub 

Sub bindingSource1_CurrentChanged(ByVal sender As Object, ByVal e As EventArgs) _
    Handles bindingSource1.CurrentChanged
    box1.Font = CType(bindingSource1.Current, Font)
End Sub

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft