使用DataBindings为控件邦定数据
Dim selectID As Int32 = 0
Dim cm As CurrencyManager
Private Sub tables_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.daMember.Fill(Me.DsMember)
Me.dgList.DataSource = Me.DsMember.Tables(0)
Me.dgList.Select(selectID)
Me.TextBox1.DataBindings.Add("Text", Me.DsMember.Tables(0), "M_UserName")
cm = Me.BindingContext(Me.DsMember.Tables(0))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SelectID += 1
Me.dgList.UnSelect(SelectID - 1)
Me.dgList.Select(selectID)
cm.Position = selectID
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
selectID -= 1
Me.dgList.UnSelect(selectID + 1)
Me.dgList.Select(selectID)
cm.Position = selectID
End Sub
Dim cm As CurrencyManager
Private Sub tables_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.daMember.Fill(Me.DsMember)
Me.dgList.DataSource = Me.DsMember.Tables(0)
Me.dgList.Select(selectID)
Me.TextBox1.DataBindings.Add("Text", Me.DsMember.Tables(0), "M_UserName")
cm = Me.BindingContext(Me.DsMember.Tables(0))
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
SelectID += 1
Me.dgList.UnSelect(SelectID - 1)
Me.dgList.Select(selectID)
cm.Position = selectID
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
selectID -= 1
Me.dgList.UnSelect(selectID + 1)
Me.dgList.Select(selectID)
cm.Position = selectID
End Sub