Home All Groups Group Topic Archive Search About

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

Author
2 Jun 2006 3:37 AM
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

Author
2 Jun 2006 5:37 AM
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" <the_sam_mal***@hotmail.com> schreef in bericht news:eYa6kXfhGHA.4276@TK2MSFTNGP03.phx.gbl...
  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
Author
2 Jun 2006 1:40 PM
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.
  "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eUKugZghGHA.5104@TK2MSFTNGP04.phx.gbl...
  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" <the_sam_mal***@hotmail.com> schreef in bericht news:eYa6kXfhGHA.4276@TK2MSFTNGP03.phx.gbl...
    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