Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><em>I hope I did get you right...</em> I created a <em>small sample form</em>. On <strong>SelectedIndexChanged</strong> of a <strong>comboBox</strong> I will <strong>show</strong> the <strong>filtered aucCars</strong>. ComboBoxes gets their <em>data from xml file</em> according to given details in question <code>(Web_Series, Model_Type, Model_Year - distinct)</code></p> <pre><code>// get data from file XElement aucCars = XElement.Load("data.xml"); private void cmbSeries_SelectedIndexChanged(object sender, EventArgs e) { if (cmbSeries.SelectedItem != null) { string currentSeries = cmbSeries.SelectedItem.ToString(); var models = (from a in aucCars.Elements() where a.Element("Web_Series").Value == currentSeries select a.Element("Model_Type").Value).Distinct().ToList(); cmbModel.DataSource = models; } showAucCars(); } private void cmbModel_SelectedIndexChanged(object sender, EventArgs e) { if (cmbModel.SelectedItem != null) { string currentSeries = cmbSeries.SelectedItem.ToString(); string currentModel = cmbModel.SelectedItem.ToString(); var years = (from a in aucCars.Elements() where a.Element("Web_Series").Value == currentSeries &amp;&amp; a.Element("Model_Type").Value == currentModel select a.Element("Model_Year").Value).Distinct().ToList(); cmbYear.DataSource = years; } showAucCars(); } private void cmbYear_SelectedIndexChanged(object sender, EventArgs e) { showAucCars(); } private void frmXmlLoad_Load(object sender, EventArgs e) { var series = (from a in aucCars.Elements() select a.Element("Web_Series").Value).Distinct().ToList(); cmbSeries.DataSource = series; } private void showAucCars() { var filterCars = aucCars.Elements(); if (cmbSeries.SelectedItem!=null) { string currentSeries = cmbSeries.SelectedItem.ToString(); filterCars = from a in filterCars where a.Element("Web_Series").Value == currentSeries select a; } if (cmbSeries.SelectedItem != null) { string currentModel = cmbModel.SelectedItem.ToString(); filterCars = from a in filterCars where a.Element("Model_Type").Value == currentModel select a; } if (cmbSeries.SelectedItem != null) { string currentYear = cmbYear.SelectedItem.ToString(); filterCars = from a in filterCars where a.Element("Model_Year").Value == currentYear select a; } // will show all the element data // add a new linq stmt to select specific elements listBox1.DataSource = filterCars.ToList(); } </code></pre> <p>Within <code>showAucCars()</code> I <strong>filter according to selection in comboBoxes</strong> and show result in listBox. In case you want to <em>display a specific element</em> in listbox, add a <strong>new linq stmt and select the according element(s)</strong>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload