Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would you check multiple RichTextboxes containing multiple lines for unique and or duplicate lines
    text
    copied!<p>How would you check multiple RichTextboxes containing multiple lines for unique and or duplicate lines. I've figured out how to loop through the richTextboxes and get the data, but I'm struggling on the logic to see if it's unique. My apologies if code is as clear as mud.</p> <pre><code>List&lt;string&gt; DistinctItems = new List&lt;string&gt;(); List&lt;string&gt; DupilcatedItems = new List&lt;string&gt;(); List&lt;string&gt; FirstItemsList = new List&lt;string&gt;(); List&lt;string&gt; CompareItemsList = new List&lt;string&gt;(); int ElementIndex = 0; foreach (RichTextBox c in tableLayoutPanel1.Controls) { if (c.Text != null) { FirstItemsList.Add(c.Text.Replace("\n", Environment.NewLine).ToString()); if (CompareItemsList.Count == 0) { //Have to add the first batch foreach (string str in FirstItemsList) { txtMixerTextBox.AppendText(str); txtDistinctItems.AppendText(str); DistinctItems.Add(str); ElementIndex++; } CompareItemsList.Add(c.Text.Replace("\n", Environment.NewLine).ToString()); if (CompareItemsList.Count() &gt; 0) { //OK we've gone through the first set foreach (string s in CompareItemsList) { if (DistinctItems.Contains(s)) { //It's a duplicate see if it's in the duplicate list if (DupilcatedItems.Contains(s)) { //OK it's in the list we don't have to add it //See if it's in the textbox if (!txtDuplicateItems.Text.Contains(s)) { //OK it's not in the textbox let's add it txtDuplicateItems.AppendText(s); } } } else { //It's not there so add it DupilcatedItems.Add(s); //now see if it's in the Distinct Textbox if (!txtDistinctItems.Text.Contains(s)) { //add it txtDistinctItems.AppendText(s); } txtMixerTextBox.AppendText(s); } } } } } } </code></pre>
 

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