hi ol,

i m developing a sotware where i wanna filter a column in data grid with multiple string values. eg: column1 should display string1 value or string2 value or both.. im putting those stings in a list box and when i click a button those listed values should be filterd... please help me to figure this out. any one.......

thnk you!

Recommended Answers

All 3 Replies

You can set the datatable to DefaultView and then use the RowFilter method, to only show the records that meet your filter critera. There is a general example below:

Sub ListBox1_SelectedIndexChanged

    If m_blnLoading = True Then Exit Sub

    With MyDataSet.MyTable.DefaultView
        Select Case FilterCritera
            Case Critera1
                .RowFilter = "Column1 = 0"
            Case Critera2
                .RowFilter = "Column1 = 1"
            Case Else
                .RowFilter = "Column1 = 3"
        End Select
    End With

End Sub

TomW thank you for your reply!

Actually when i click a button clolumn 1 should be filtered with values or strings in the list box. All the strings should be used to filter!

Thank you!

The example shows how you can filter data in a datatable, obviously you have to replace the values with the appropiate column names and search values you want.

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.