Populating and Filtering a combobox from XML

silks

New member
Joined
Apr 19, 2007
Messages
1
Programming Experience
1-3
Hi there

I have 5 XML files which I am loading into datasets using readxml

VB.NET:
Dim xmlMainLocReader As New XmlTextReader(ImportFile & "\xmlMainLocation.xml")
Dim dMainLoc As DataSet = New DataSet
dMainLoc.ReadXml(ImportFile & "\xmlMainLocation.xml", XmlReadMode.InferSchema)
 
Me.cmbBCem.DataSource = dMainLoc.Tables(0)
Me.cmbBCem.DisplayMember = "Description"
Me.cmbBCem.ValueMember = "ID"
Me.cmbBCem.Text = ""

This is working fine.
However the last XML file contains things I dont want to appear in the combobox.

Any suggestions on what I should use to filter this data? Unfortunately I can't alter the XML file.

Thanks

Doug
 
Last edited by a moderator:
Either delete the items from the datatable they are in, or have your combo bind through a BindingSource, which is bound to the datatable. The BindingSource.Filter property can be used to hide the unwanted rows:

myBindSource.Filter = "col1 IS NOT NULL AND col2 LIKE 'apple%'"
 
Back
Top