SlopTonio
SlopTonio

Reputation: 1105

Appending to read-only text box with different colors

I can easily append to the read-only text box but my problem is switching colors depending on which if statement is being executed:

foreach (var attribute in elements)
{
    if (File.Exists(pathtocheck))
    {
       outputLOG.AppendText("blah blah blah");
    } 
    else 
    {
       outputLOG.ForeColor = System.Drawing.Color.Red;
       outputLOG.AppendText("blah blah blah");
    }
}

GOAL: If filepath exists use black text and if it doesn't then use red text. My code above currently uses all black or all red, I want it to alternate depending on the situation.

Upvotes: 0

Views: 190

Answers (1)

Mike Dinescu
Mike Dinescu

Reputation: 55730

The standard TextBox control does not support multi-colored text (Rich-Text formatting). You will need a RichTextBox control or something similar.

Upvotes: 3

Related Questions