Is it possible to set each character in a TextBox a different colour?

Re: Set each character in TextBox a different colour? by Morten

Morten
Tue Jul 19 07:15:11 CDT 2005

Hi redneon,

No, a TextBox can only have a single Font, and therefore only one size, color, shape etc. You can use a RichTextBox though.


On Tue, 19 Jul 2005 12:39:01 +0200, redneon <redneon@discussions.microsoft.com> wrote:

> Is it possible to set each character in a TextBox a different colour?
>
>



--
Happy coding!
Morten Wennevik [C# MVP]

Re: Set each character in TextBox a different colour? by redneon

redneon
Tue Jul 19 07:21:02 CDT 2005

> No, a TextBox can only have a single Font, and therefore only one size,
color,
shape etc. You can use a RichTextBox though.

I was thinking more along the lines of overriding the paint method of the
control. Would this not allow it?


Re: Set each character in TextBox a different colour? by Herfried

Herfried
Tue Jul 19 09:46:12 CDT 2005

"redneon" <redneon@discussions.microsoft.com> schrieb:
>> No, a TextBox can only have a single Font, and therefore only one size,
> color,
> shape etc. You can use a RichTextBox though.
>
> I was thinking more along the lines of overriding the paint method of the
> control. Would this not allow it?

The TextBox control is drawn by Windows, thus it's not as easy to implement
the functionality you want to archieve. I suggest to use the RichTextBox
control instead of the textbox too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>