Adding color to strings independent of any controls

Bam

Member
Joined
Oct 19, 2005
Messages
15
Location
Ireland
Programming Experience
Beginner
" Hi i have 2 slightly different text editors i made in VB.
NET 2005 Express. Im currently working on a syntax checker which when completed i hope to add into these two projects and give away as a self contained class to help people understand the advantages of OOP. The problem im having is changing the color of Keywords.
I was wondering is there a way to change the color of certain key words in a string after they have been pulled from richbox.text or textbox.text to the string varible.
The reason for this is to keep the class as independent as possible ?
Thanks
 
There is at present no way of specifying the format of the content of a plain text string variable.

There are two strategies you could employ.

Include formatting markup in the string itself. eg: " blah blah blah <Red>bla blah</Red> blah blah blah" - you could use html markup or devise your own. This would be stripped out and used when the string is rendered.

The best way to do it would be to write you own rendering engine which takes your string and formats it according to the engine rules. (so you would need to do keyword searches etc etc)


Both of these approaches will require a significant amount of coding on your part. Do you need to do this? Could you not store the RichText markup in the string rather than the plain text? (i.e. use the .rtf rather than the .Text property)
 
Back
Top