Michael A
Michael A

Reputation: 5840

Show String on control with words in diffrent colors

In my app i am showing stocks quotes.

I am using a string with few stocks and its quotes and show it in a kind of marquee control. Is it possible to print the String and show it on the control so that a few words will be in red(the descending stocks) and a few in green(the rising ones)?

Upvotes: 0

Views: 127

Answers (2)

sobby01
sobby01

Reputation: 2154

Use rich text box and you can do something in richTextBox1_PreviewKeyDown event of rich text box

private void richTextBox1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (richTextBox1.SelectionColor != Color.Red)
            {
                richTextBox1.SelectionColor = Color.Red;
            }
            if (e.KeyCode == Keys.Enter)
            {
                richTextBox1.SelectionColor = Color.Blue;
            }
        }

Upvotes: 0

Bala R
Bala R

Reputation: 108937

You can do that very easily with a RichTextBox. This post has a simple example.

Upvotes: 2

Related Questions