Dynamically filter text displayed based on user input
<p>I am trying to make a tool to take a formatted text file that stores our logging information and returns only certain parts of it. For example the log file looks something like this:</p>

<pre><code>[TimeStamp] &lt;Config&gt;: Configuration note is shown here
[TimeStamp] &lt;Info&gt;: Information is written here   
[TimeStamp] &lt;Info&gt;: More Information
[TimeStamp] &lt;Step&gt;: A generated step is writing a message
[TimeStamp] &lt;Warning&gt;: A warning is logged
[TimeStamp] &lt;Error&gt;: An error has occurred
</code></pre>

<p>I would like to take this text from the file, and based on checkboxes for each log message type in the angle brackets, the user can hide what they don't care to see. Such as unchecking the 'Step' checkbox would hide the Step line, but if they were to recheck it, it would reappear in the text window.</p>

<p>I tried storing each line into a string which is stored in a list to keep each line in order, however this method is very very slow at changing the text. The method is shown below</p>

<pre><code>logTextbox.Text = "";
foreach (string line in CompleteLog) //CompleteLog is list containing each line in log file
{
   if (CheckLine(line)) //Checks line based on what the user wants to see
   {
      WriteLine(line);
   }
}
</code></pre>

<p>Any suggestions would be very welcome</p>

<p>Edit:</p>

<pre><code>        private bool CheckLine(string line)
    {
        int left = line.IndexOf('&lt;');
        int right = line.IndexOf("&gt;:");

        string logtype = line.Substring(left+1, right - left-1);
        if (ValidLogs.Any(p =&gt; p.ToLower().Equals(logtype.ToLower())))
        {
            return true;
        }

        return false;
    }
</code></pre>

<p>ValidLogs is a list of strings that contain what is allowed that is setup on load, and changed on a check event for the checkboxes corresponding to the log type. The 1st method above is used on load and each check event to update what is displayed.</p>
