Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
So, as of right now I am having problems manually binding to a table that is filtered. in form 1 I have the filter set with an sql query. If I do not run the filter code I can navigate and select rows using gridview. Once I use the filter the record selected comes out to be record 1-5 depending if I select the 5th row or not. how can someone reference the filtered table in form1 to use in form2?

What I have tried:

I have tried to create another table in form2, but I can't use it cause it will reference all records.
Posted
Updated 17-Aug-17 21:42pm

1 solution

Try below code..

Public Class frm1
     Public dtSongs As DataTable

     'the datatable is filled in the form somewhere

     Public Sub OpenForm3
          Dim frmTemp As New frm3(Me)

          frmTemp.Show()
     End Sub
End Class

'Form 3
Public Class frm3
     Dim myInstanceOffrm1 As frm1

     Public Sub New(ByVal Passfrm1 As frm1)

          myInstanceOffrm1 = Passfrm1

     End Sub

     Public Sub GetForm1DataTable()
          'Access the DataTable
          myInstanceOffrm1.dtSongs        
          
     End Sub
End Class
 
Share this answer
 
v2
Comments
Member 11856456 18-Aug-17 8:58am    
I have yet to venture into creating classes, where do I put the code? is it in form 1?
Atlapure Ambrish 18-Aug-17 10:23am    
I have used frm1 and frm3 in example, so, the code in frm1 should go to form1.cs and frm3 should go to form2.cs if you have classes. Otherwise refer it as example, it shows how you can access it another form.

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