populate a datagridview from tab control

J

jdrott1

i have a tab named tEmployeeInfo. when the tab is clicked i want to
load a datagridview on the same form, but it is not in the tab
control. i can use this code in the form load event and the datagrid
will populate, but it will not populate if i change it to the
tEmployeeInfo_Click: (when the tab is clicked i want it to load this
data in the grid)

Private Sub tEmployeeInfo_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tEmployeeInfo.Click

Dim taCashier As New
dsEmployee_EntryTableAdapters.GetTable_CashierInfloTableAdapter
Dim CashierDetails As New
dsEmployee_Entry.GetTable_CashierInfloDataTable

taCashier.Fill(CashierDetails)
'Me.dataGrid1.DataSource = Nothing
Me.dataGrid1.DataSource = CashierDetails

End Sub
 
J

jdrott1

i have a tab named tEmployeeInfo.  when the tab is clicked i want to
load a datagridview on the same form, but it is not in the tab
control.  i can use this code in the form load event and the datagrid
will populate, but it will not populate if i change it to the
tEmployeeInfo_Click: (when the tab is clicked i want it to load this
data in the grid)

Private Sub tEmployeeInfo_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles tEmployeeInfo.Click

        Dim taCashier As New
dsEmployee_EntryTableAdapters.GetTable_CashierInfloTableAdapter
        Dim CashierDetails As New
dsEmployee_Entry.GetTable_CashierInfloDataTable

        taCashier.Fill(CashierDetails)
        'Me.dataGrid1.DataSource = Nothing
        Me.dataGrid1.DataSource = CashierDetails

    End Sub

got it with this:

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
'This loop is used to load the datagridview with data for the
corresponding tab.
If tEmployeeInfo.Focus = True Then
Dim taCashier As New
dsEmployee_EntryTableAdapters.GetTable_CashierInfloTableAdapter
Dim CashierDetails As New
dsEmployee_Entry.GetTable_CashierInfloDataTable

taCashier.Fill(CashierDetails)
Me.dataGrid1.DataSource = Nothing
Me.dataGrid1.DataSource = CashierDetails
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top