Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListBox filter

Status
Not open for further replies.

Frihi

Programmer
Jun 24, 2001
48
CH
I have a ListBox, bound to a DataSet. It displays column1 of the DataSet. Now I want to filter column2 so that the ListBox only displays the rows found with the filtervalue (from a textLabel) in column2.

Dim foundRow As DataRow
Dim findTheseVals(0) As Object
findTheseVals(0) = lblFilter.Text
foundRow = (Me.objDataSet1.Tables("MyTable").Rows.Find(findTheseVals))

If Not (foundRow Is Nothing) Then
Try

' Well, here I'm stucked. Looking for something like:

ListBox1.Select(findTheseVals)

Catch eEndEdit As System.Exception
System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
End Try
End If

Anybody with a hint?

Thanks

Fritz
 
Meanwhile I've been trying other ways. First I took the direct databinding off. And I have another Listbox with the values to search in MyTable.
And now I have this code:

Dim i, x As Integer
x = Me.objDataSet1.Tables("MyTable").Rows.Count - 1

For i = 0 To x
If Me.ListBox3.SelectedItem = lblXLand.Text Then
Me.ListBox2.Items.Insert(i, Me.lblName.Text)
Me.BindingContext(objDataSet1, "MyTable").Position = Me.BindingContext(objDataSet1, "MyTable").Position + 1
End If

Next i

This is basically filling the Listbox, but only with the first value given in lblXLand.Text. When the value changes it doesn't work anymore.

Would really appreciate some help, thanks.

Fritz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top