Barroso6 Posted April 20, 2021 at 05:58 PM Report Share #622055 Posted April 20, 2021 at 05:58 PM 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now