hi everyone!

need help in using all the listbox contents for filtering a datagridview2 (that is binded with an access database)

my code is as follows:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim tables As DataTableCollection = VPC_DatabaseDataSet.Tables
        Dim view1 As New DataView(tables(4))
        Dim source1 As New BindingSource()
        source1.DataSource = view1
        CHICK_DELIV_ORDERDataGridView.DataSource = source1

        Me.CHICK_DELIV_ORDERTableAdapter.Fill(Me.VPC_DatabaseDataSet.CHICK_DELIV_ORDER)
        source1.Filter = " BATCH_N =  '" & TextBox1.Text & "'"


        Dim view2 As New DataView(tables(3))
        Dim source2 As New BindingSource()
        source2.DataSource = view2
        CHICK_BOXDataGridView.DataSource = source2


        Me.CHICK_BOXTableAdapter.Fill(Me.VPC_DatabaseDataSet.CHICK_BOX)
        source2.Filter = " CHICK_DELIV_ORDER_N = ' " & ListBox1.Text & "'"

End Sub

the listbox has the same content (chick deliv order N as in the datagridview1)
the listbox contents are numbers:
100101
100102
100103


the code above is working, however, the datagridview2 only displays only the matches for the first entry in the listbox, which is 100101. it does'nt include the matches for the other two contents in the listbox.

hope somebody can help.
thanks!

Recommended Answers

All 4 Replies

Member Avatar for DearDhruv

friend Try Data reader so u can scan the data until there is no data or mismatch the data....

Thanks

friend Try Data reader so u can scan the data until there is no data or mismatch the data....

Thanks

Hi DearDhruv! Thanks for the reply.
But, can you be more specific on how I can use the Data Reader? How do I go about the syntax code for that?

Hope to hear from you again. Thanks!

Also, I am already using TableAdapters (from Adding Data Source)

Can use data reader simultaneously with TableAdapters?

Take a look at this sample,

Public Class Form1
    Dim source1 As New BindingSource
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim dt As New Data.DataTable
        dt.Columns.Add("Name")
        dt.Rows.Add("foo")
        dt.Rows.Add("bar")
        dt.Rows.Add("baar")
        dt.Rows.Add("taj")

        Dim view1 As New Data.DataView(dt)

        source1.DataSource = view1
        DataGridView1.DataSource = source1

    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        source1.Filter = "Name like '%" & ListBox1.Text & "%'"
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.