vb.net - I have one XML file but two combo boxes I want to populate the second one depending on the first -


I have two comboboxes on my application. First combx can get all the necessary data (in this case this is the factory number ) However, on the basis of factory selection, I want the next combo box (in this case line number) to automatically populate with the right lines for the factory. Here is my XML file - or a test data

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Profile & gt; & Lt; Factories & gt; & Lt; Factory & gt; F1 & lt; / Factory & gt; & Lt; Factory & gt; F2 & lt; / Factory & gt; & Lt; Factory & gt; F3 & lt; / Factory & gt; & Lt; Factory & gt; F4 & lt; / Factory & gt; & Lt; Factory & gt; F5 & lt; / Factory & gt; & Lt; Factory & gt; F6 & lt; / Factory & gt; & Lt; Factory & gt; F7 & lt; / Factory & gt; & Lt; Factory & gt; F8 & lt; / Factory & gt; & Lt; / Factories & gt; & Lt; Lines & gt; & Lt; F1 & gt; G1 & lt; / F1> & Lt; F1 & gt; G2 & lt; / F1> & Lt; F1 & gt; G3 & lt; / F1> & Lt; / Lines & gt; & Lt; / Profile & gt;   

Here's what I have so far:

  private sub populateComboBoxes () Dim Dock New XmlDocument () doc.Load ( "as in C: \ TFS2010Source \ ShopFloorApps \ main \ source \ Components \ 000280LinePCBackup \ 000280LinePCBackup \ Lines.XML ") dim factoryList as XmlNodeList = doc.SelectNodes (" / profiles / factories / Factory ") as each factory XmlNode factoryList factoryComboBox.Items.Add for (Factory .InnerText) Next End sub Private sub factoryComboBox_SelectedIndexChanged (ByVal Rs as the System.Object, ByVal e System.EventArgs) as handle factoryComboBox.SelectedIndexChanged dim dock New XmlDocument ( In) doc.Load ( "C: \ TFS2010Source \ ShopFloorApps \ main \ source \ Components \ 000280LinePCBackup \ 000280LinePCBackup \ Lines.XML") Dim lineList as XmlNodeList = doc.SelectNodes ( "/ profiles / Lines"), each row factoryComboBox. SelectedItem.ToString = line.FirstChild.Name then in the lineComboBox XmlNode lineList as for. item. Add (Line.Pasteur Child.Intext) end if the next end sub   

So what do I want when I seal ect F1 other tells the line fills with G1, G2 and G3 .

thanks

item of lineComboBox To clean and also replace the SelecteNodes path.

  lineComboBox.Items.Clear () Dim lineList as XmlNodeList = doc.SelectNodes ( "/ profiles / Lines /" & amp; factoryComboBox.SelectedItem.ToString) as per line XmlNode lineList lineComboBox In for item. Add (Line.PasteurChild.Intext) Next    

Comments