Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I was given an task to pull data from the current row to the textbox and then navigate to the next or previous record.
i tried my level best to achieve my task i have succeeded to pull the current row from datagrid to textbox but can not move to the next or previous record.
My code is as follows any kind of help will be deeply appreciated.

VB
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.dagrid.Fill(Me.Dsgrid)
    End Sub

    Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        Dim i As Integer
        i = DataGridView1.CurrentRow.Index
        TextBox1.Text = DataGridView1.Item(0, i).Value
        TextBox2.Text = DataGridView1.Item(1, i).Value
    End Sub

    Private Sub btnnext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnext.Click
        Me.BindingContext(Dsgrid, "Customers").Position += i
    End Sub
End Class
Posted
Updated 7-Apr-11 20:55pm
v2

1 solution

Here is a very simple example which explains navigating the records using BindingContext.

http://www.startvbdotnet.com/ado/simplebinding1.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900