Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you refresh textbox data after DataSet navigation? 1

Status
Not open for further replies.

emaduddeen

Programmer
Mar 22, 2007
184
0
0
US
Hi Everyone,

I'm experimenting with manually navigating through a DataSet created by the wizard.

Please check my navigation code. I can navigate ok through the DataSet but the data on the form is not refreshing. Can you tell me how to refresh it?

I already tried to use: Me.Refresh() but I can see this is not the correct code to use.

Here's the code:

Code:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' This line of code loads data into the 'NoveltyDataSet.tblCustomer' table. 
        ' You can move, or remove it, as needed.
        '--------------------------------------------------------------------------
        Me.TblCustomerTableAdapter.Fill(Me.NoveltyDataSet.tblCustomer)

    End Sub

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        ' Navigate forward 1 position in the DataSet.
        '--------------------------------------------
        Me.BindingContext(NoveltyDataSet, "tblCustomer").Position += 1

        Me.Refresh()

        With Me.BindingContext(NoveltyDataSet, "tblCustomer")
            lblDataStatus.Text = "Record " & .Position + 1 & " of " & .Count
        End With
    End Sub

    Private Sub btnPrevious_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrevious.Click
        ' Navigate forward 1 position in the DataSet.
        '--------------------------------------------
        Me.BindingContext(NoveltyDataSet, "tblCustomer").Position -= 1

        Me.Refresh()

        With Me.BindingContext(NoveltyDataSet, "tblCustomer")
            lblDataStatus.Text = "Record " & .Position + 1 & " of " & .Count
        End With
    End Sub

Thanks.

Truly,
Emad
 

Why not use the bindingsource such as:

TableCustomerBindingSource.MoveNext
TableCustomerBindingSource.MovePrevious
TableCustomerBindingSource.MoveFirst
TableCustomerBindingSource.MoveLast

Everything should update automatically.
 
Hi kliot,

That worked.

Thanks for the reply and helpful code.

Truly,
Emad
 
Glad to help, I should have also mentioned

TableCustomerBindingSource.Position
To get the current position

TableCustomerBindingSource.Count
To get the number of records

lblDataStatus.Text = "Record " & TableCustomerBindingSource.Position + 1 & " of " & TableCustomerBindingSource.Count
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top