Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I can see your function returns only one element by design. You try to loop trough query but <code>return item;</code> statement will always return first element in the query. Maybe you need to change it's return type to <code>IEnumerable&lt;ListViewItem&gt;</code> and replace <code>return item;</code> to <code>yield return item;</code> for example?</p> <p>For your case I would suggest the following change for <code>getDMcollection</code> function:</p> <pre><code>public IEnumerable&lt;ListViewItem&gt; getDMcollection(string sys) { XDocument doc = XDocument.Load(Form1.CSDBpath + Form1.projectName + "\\Data.xml"); var dms = from dm in doc.Descendants("dataModule") where dm.Descendants("system").First().Value == sys select dm; foreach (var module in dms) { ListViewItem item = new ListViewItem(new string[] { module.Element("DMC").Value, module.Element("techName").Value, module.Element("infoName").Value, module.Element("status").Value, module.Element("currentUser").Value, module.Element("validator").Value, module.Element("notes").Value, //dm.Element("size").Value + " kb", //dm.Element("dateMod").Value }); yield return item; } } </code></pre> <p>when you call to it, you should iterate it's result to add them to list box</p> <pre><code>public IEnumerable&lt;ListViewItem&gt; splitSNS(string fullSNSpath) { string sns = new String(fullSNSpath.ToCharArray().Where(c =&gt; Char.IsDigit(c)).ToArray()); if (sns.Length.ToString() == "6") { string sys = sns.Substring(4, 2); string subsys = sns.Substring(2, 2); string unit = sns.Substring(0, 2); IEnumerable&lt;ListViewItem&gt; dms = getDMcollection(sys, subsys, unit); foreach(var d in dms) yield return d; } else if (sns.Length.ToString() == "4") { string sys = sns.Substring(2, 2); string subsys = sns.Substring(0, 2); IEnumerable&lt;ListViewItem&gt; dms = getDMcollection(sys, subsys); foreach(var d in dms) yield return d; } else if (sns.Length.ToString() == "2") { string sys = sns.Substring(0, 2); IEnumerable&lt;ListViewItem&gt; dms = getDMcollection(sys); foreach(var d in dms) yield return d; } } </code></pre> <p>And finally...</p> <pre><code>IEnumerable&lt;ListViewItem&gt; dms = newFilter.splitSNS(fullSNSpath); if (dms.Any()) { // showfilteredList(dms); foreach(var d in dms) listView1.Items.Add(d); showStatus(dms); } else { MessageBox.Show("There are no DMs to be displayed"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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