Why doesn't changing the position in a table change the position of the DatGridView that's bound to

S

Sam Malone

I have these four methods to change the position in a table. However when I invoke any of them nothing appears to happen to the table. It doesn't scroll. The selector pointer doesn't move. Nada!!
If I check the row in the table (DataTable2), it IS changing as it should and the DGV IS bound to the data table.

Private Sub cmdFirst_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFirst.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = 0
End Sub
Private Sub cmdLast_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLast.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = MyDataSet.Tables("DataTable2").Rows.Count
End Sub
Private Sub cmdNext_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNext.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position < MyDataSet.Tables("DataTable2").Rows.Count Then
BindingContext(MyDataSet.Tables("DataTable2")).Position += 1
End If
End Sub
Private Sub cmdPrevious_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPrevious.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position > 0 Then
BindingContext(MyDataSet.Tables("DataTable2")).Position -= 1
End If
End Sub
 
C

Cor Ligthert [MVP]

Sam,

In version 2005 it is easier to use the bindingsource.

See this sample on our webview
http://www.vb-tips.com/default.aspx?ID=869eb278-0b5f-4dfd-8068-4e3f3fedb997

I hope this helps,

Cor
"Sam Malone" <[email protected]> schreef in bericht I have these four methods to change the position in a table. However when I invoke any of them nothing appears to happen to the table. It doesn't scroll. The selector pointer doesn't move. Nada!!
If I check the row in the table (DataTable2), it IS changing as it should and the DGV IS bound to the data table.

Private Sub cmdFirst_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFirst.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = 0
End Sub
Private Sub cmdLast_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLast.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = MyDataSet.Tables("DataTable2").Rows.Count
End Sub
Private Sub cmdNext_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNext.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position < MyDataSet.Tables("DataTable2").Rows.Count Then
BindingContext(MyDataSet.Tables("DataTable2")).Position += 1
End If
End Sub
Private Sub cmdPrevious_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPrevious.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position > 0 Then
BindingContext(MyDataSet.Tables("DataTable2")).Position -= 1
End If
End Sub
 
S

Sam Malone

OH GOODIE!!! and just when I thought I was beginning to understand the other stuff :=) Thanks a bunch. I'll have a look at it, Cor. Appreciate the help.
Sam,

In version 2005 it is easier to use the bindingsource.

See this sample on our webview
http://www.vb-tips.com/default.aspx?ID=869eb278-0b5f-4dfd-8068-4e3f3fedb997

I hope this helps,

Cor
"Sam Malone" <[email protected]> schreef in bericht I have these four methods to change the position in a table. However when I invoke any of them nothing appears to happen to the table. It doesn't scroll. The selector pointer doesn't move. Nada!!
If I check the row in the table (DataTable2), it IS changing as it should and the DGV IS bound to the data table.

Private Sub cmdFirst_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdFirst.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = 0
End Sub
Private Sub cmdLast_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdLast.Click
BindingContext(MyDataSet.Tables("DataTable2")).Position = MyDataSet.Tables("DataTable2").Rows.Count
End Sub
Private Sub cmdNext_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdNext.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position < MyDataSet.Tables("DataTable2").Rows.Count Then
BindingContext(MyDataSet.Tables("DataTable2")).Position += 1
End If
End Sub
Private Sub cmdPrevious_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdPrevious.Click
If BindingContext(MyDataSet.Tables("DataTable2")).Position > 0 Then
BindingContext(MyDataSet.Tables("DataTable2")).Position -= 1
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top