BindingSource.MoveNext Method

Note: This method is new in the .NET Framework version 2.0.

Moves to the next item in the list.

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

public void MoveNext ()
public void MoveNext ()
public function MoveNext ()

Changes the current value of the Position property to the next item in the underlying data source.

The following code example demonstrates the MoveNext, MoveFirst, Current, and Position members. To run this example, paste the code into a form that imports the System.Drawing.Drawing2D namespace and contains a BindingSource named BindingSource1 and a button named button1. Associate the Form1_Load and Form1_Paint methods with the Load and Paint events for the form, and associate the button1_click method with the Click event for button1. Visual Basic users will need to add a reference to System.Data.dll.

void Form1_Load(object sender, EventArgs e)
    // Set the data source to the Brush type and populate
    // BindingSource1 with some brushes.
    BindingSource1.DataSource = typeof(System.Drawing.Brush);
        new TextureBrush(new Bitmap(typeof(Button), "Button.bmp")));
    BindingSource1.Add(new HatchBrush(HatchStyle.Cross, Color.Red));
    BindingSource1.Add(new SolidBrush(Color.Blue));

private void button1_Click(object sender, EventArgs e)
    // If you are not at the end of the list, move to the next item
    // in the BindingSource.
    if (BindingSource1.Position + 1 < BindingSource1.Count)

    // Otherwise, move back to the first item.

    // Force the form to repaint.

void Form1_Paint(object sender, PaintEventArgs e)
    // Get the current item in the BindingSource.
    Brush item = (Brush)BindingSource1.Current;

    // If the current type is a TextureBrush, fill an ellipse.
    if (item.GetType() == typeof(TextureBrush))

    // If the current type is a HatchBrush, fill a triangle.
    else if (item.GetType() == typeof(HatchBrush))
            new Point[] { new Point(0, 0), new Point(0, 200),
            new Point(200, 0)});

    // Otherwise, fill a rectangle.
            (Brush)BindingSource1.Current, e.ClipRectangle);

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

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

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0