Re: Displaying Multicolored text in a control
- From: "Kevin Spencer" <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 21 May 2006 11:57:30 -0400
Your first attempt was the correct one. Set the BackgroundColor of the
RichTextBox to black. You can then set the color of any text by using the
SelectionColor property when adding the text.
Set the SelectionColor property and then use AppendText to add some text in
that color. Reset the SelectionColor property and use AppendText to add some
more text in the new color. Etc.
--
HTH,
Kevin Spencer
Microsoft MVP
Professional Numbskull
The man who questions opinions is wise.
The man who quarrels with facts is a fool.
<ChrisUttenreither@xxxxxxxxx> wrote in message
news:1148225464.112076.222460@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello folks. I'm writing a Roguelike game in C#. Fun stuff. The game
includes a map that is made entirely of colored ASCII art in a
monospace font. I would like to make this map a control in the main
form.
My first attempt was with RichTextBox. I wanted to set the background
to black. After cruising newsgroups I determined that wasn't possible.
My second attempt involves an AxSHDocVw.AxWebBrowser control. I got
this by adding the "Microsoft Web Browser" control to my Toolbox. This
control does not play nicely with the rest of my form! It constantly
steals focus for itself, and there isn't a reliable mechanism for
forcing my main form to have focus. Since that control is not set up
to handle keyboard events (this is how the player moves through the
map) other people on newsgroups have been told to write an unmanaged
DLL that snags a (global?) hook and signals my application when
keyboard input has been entered.
That seems awfully complicated. A wise software engineer once told me
when a solution seems inordinately complex that I should ask if there's
a better solution. So that's the purpose of my message. :) I want to
display multicolored text in a form control. I want to be able to
change the background as well as the foreground, and I want to be able
to acquire keyboard input without writing a bunch of low level code.
What is the best solution? What is the best control to use? I am
using .NET 1.0.
Thanks!
.
- References:
- Displaying Multicolored text in a control
- From: ChrisUttenreither
- Displaying Multicolored text in a control
- Prev by Date: Re: DataGridView columns
- Next by Date: Re: DataGridView columns
- Previous by thread: Re: Displaying Multicolored text in a control
- Next by thread: Re: Displaying Multicolored text in a control
- Index(es):
Relevant Pages
|