Click here to Skip to main content
15,891,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 DataGridView on form. In datagridview1 ID ,FirstName ,LastName of the columns so that I made a list.When I chose any name that I'm relaying the information that was connected to datagridview2. but this process happens 1 times.so another ID when clicked 2. DataGrid is not refreshed. How do I fix this?

Note: Sorry my english

Code:
VB
Sub listele()
        koopTablo.Clear()
        makbuzTablo.Clear()
        bag.Open()
        adtr = New OleDbDataAdapter("select plaka,adi,soyadi From koop", bag)
        adtr.Fill(koopTablo)
        DataGridView1.DataSource = koopTablo
        DataGridView1.Columns(0).HeaderText = "PLAKA"
        DataGridView1.Columns(1).HeaderText = "Adı"
        DataGridView1.Columns(2).HeaderText = "Soyadı"
        DataGridView1.Refresh()

        bag.Close()
        adtr.Dispose()
    End Sub



    Sub sec()

        Try

            If DataGridView1.CurrentRow.Cells(0).Value.ToString().Trim() <> "" Then
                
                bag.Open()
                kmt.Connection = bag
                adtr = New OleDbDataAdapter("SELECT Makbuzno,Donem,Tarih,Miktar from Makbuz WHERE PLAKA='" & DataGridView1.CurrentRow.Cells(0).Value.ToString() & "'", bag)
                adtr.Fill(makbuzTablo)
                DataGridView2.DataSource = makbuzTablo
                DataGridView2.Refresh()
                kmt.ExecuteNonQuery() 
                listele()

                bag.Close()
                kmt.Dispose()
            End If
        Catch

        End Try
    End Sub

Private Sub Form5_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        listele()
        sec()
    End Sub
Posted
Comments
SergenK 8-Jul-15 11:01am    
Private Sub DataGridView1_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged
sec()
End Sub
But doesn't work

1 solution

you should put sec() routine to datagridview1.selectionChanged() event, so that datagridview2 data is updated when selection in datagridview1 changes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900