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!

Edited 6 Years Ago by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

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
This article has been dead for over six months. Start a new discussion instead.