Jump to content

Previous and Next btn


Recommended Posts

Barroso6

Ola estou a desenvolver um trabalho para a escola o programa mostra nos locais onde pudemos lavar o nosso carro e o custo da lavagens

antes tinha (me.databinding.movenext(ou previous se fosse o caso)).

só que depois o que acontecia era que ao criar novos registos na base de dados os novos registos não eram vistos nos botões ao ter esse problema resolvi colocar uma datagriedview e sempre que clica-mos numa linha mostra nos os dados de cada empresa. Como é um instrumento de avaliação gostava que tivesse a parte gráfica apresentável dai querer usar aqueles botões 

Se me puderem ajudar ficaria grato 

Cumprimentos aguardo resposta :3

(mods se tiver feito algo errado desculpem é o meu 1 post)

 Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Database1DataSet.Empresas' table. You can move, or remove it, as needed.
        userlbl.Text = My.Settings.Nome
        Me.HorizontalScroll.Maximum = 0
        Me.AutoScroll = True
        Try
            Dim sql As String
            Dim cmd As New OleDb.OleDbCommand
            Dim dt As New DataTable
            Dim da As New OleDb.OleDbDataAdapter
            DBcon.Open()
            sql = "Select * from Empresas"
            cmd.Connection = DBcon
            cmd.CommandText = sql
            da.SelectCommand = cmd
            da.Fill(dt)
            DataGridView1.DataSource = dt
            tbid.Text = DataGridView1.CurrentRow.Cells(0).Value
            lblestabelecimento.Text = DataGridView1.CurrentRow.Cells(1).Value
            btnpreco.Text = DataGridView1.CurrentRow.Cells(2).Value
            btnpagamento.Text = DataGridView1.CurrentRow.Cells(3).Value
            btnemail.Text = DataGridView1.CurrentRow.Cells(4).Value
            btntelefone.Text = DataGridView1.CurrentRow.Cells(5).Value
            btnhorario.Text = DataGridView1.CurrentRow.Cells(6).Value
            btnendereco.Text = DataGridView1.CurrentRow.Cells(7).Value
            btndistrito.Text = DataGridView1.CurrentRow.Cells(8).Value
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            DBcon.Close()
        End Try
    End Sub
      Private Sub DataGridView1_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellClick
        tbid.Text = DataGridView1.CurrentRow.Cells(0).Value
        lblestabelecimento.Text = DataGridView1.CurrentRow.Cells(1).Value
        btnpreco.Text = DataGridView1.CurrentRow.Cells(2).Value
        btnpagamento.Text = DataGridView1.CurrentRow.Cells(3).Value
        btnemail.Text = DataGridView1.CurrentRow.Cells(4).Value
        btntelefone.Text = DataGridView1.CurrentRow.Cells(5).Value
        btnhorario.Text = DataGridView1.CurrentRow.Cells(6).Value
        btnendereco.Text = DataGridView1.CurrentRow.Cells(7).Value
        btndistrito.Text = DataGridView1.CurrentRow.Cells(8).Value
    End Sub

 

 

Edited by Barroso6
ordem do codigo
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.