Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'd like to build a text box where I can do the following:

1. to change font

2. to specify the color of certain letters, for example, to tell the program to make all the letter 'C' in the text red. I don't mean to manually highlight a letter and change its color, I want the program to change the color of the specified letters in the whole text automatically into the color I want.

 

I think I can use a rich text box to change font, but I don't know how to do the 2nd task. I am very interested in this program which outputs characters in different colores

http://msdn.microsoft.com/archive/d...msdn_msdn34.asp

but don't know how to make it work in VB.NET. I don't know where is the paint event? I also got compiling error like 'Line' is not supported in VB.NET.

 

 

any help is highly appreciated!

Posted

Try Using the KeyPress-Event, there you can evaluate which Key is pressed and do whatever you like.

 

No Coding, as I'm not sure if I'm with the correct language at the moment;) , due to different projects on different environments.

Methods/Functions to be needed should be something like select (not sure about that one) and TextColor.

 

Code will follow if you need.

 

BTW, the link you added led to nowhere.

 

Voca

Posted

if it is syntax highlighting you need in .net

well i won't tell it to you softly

.net framework is to slow to add this functionality to a richtextbox

and in a textbox well i wasn't able to create one base one a textbox but if you can please let me know

there is another option thats creating a new textcontrol from scratch wich is fun if you considder this last option i'm willing to help you.

but it is a pain in the i can tell you this youcould just get a commercial one like

compona or

syncfusion offers

there are a few other options like using a Com control

there are 2 freeware opensource options in that case

sintilla and brainchild

but they are com and a bit old but one you saw the one from compona you will never want to use the above ones

wathever so if you considder creating one from scratch i willing to help just let me know.

Posted
Engine252, how did you come up with this? .... ".net framework is to slow to add this functionality to a richtextbox"

I'd like to know that, too. I've never found anything .net-Framework wasn't able doing or where there was no easy workaround (noncommercial!).

 

Thanks for the link.

 

Voca

Posted

ok sorry for this late repply but when you do syntax highlighting in

a richtex box.

 

i'll give you a small explenation of how sintaxhighlighting works

 

you need to have a list a words that need to be highlighted.

 

then in the richtextbox you would need to on each keypress event

search the entire box if a word that is in the list of words

if you got a textbox with 1000 words it will probably take 0.5 sec to do just the searching in .net if that word is then found you need to select it color it and then go back to the place where the user left his carret.

 

wath if the user can type 300 hits a minute???

 

it is possible to implement such feature in a richtexbox but it will be slow ... very slow. not to speak of the flickering it will do after processing larger peases of code

 

did you never wonder why the code you create is so small??

all classes are bundled in external dll's

 

if you create an application with a form it loads 16 dll's

 

that makes the code slow.

.net 2 should be faster but 1.1 is still slow.

 

i don't want to flame anything here but ... i tryed implementing to a richtextbox before and believe me i know

 

a richtexbox has always been to slow for such things

if you look to all good sintax highlighting controls they are all written from scratch would all these programmers be wrong???

don't you think they would empliment it in a richtextbox if it was possible even the syntaxcontrol microsoft uses for there IDE isn't based on a richtextbox...

Posted
what about using the .Leave? You'd still have to have a list of words to check but, that way you're not looping through the whole textbox with each key stroke. You could even have it run on a seperate thread so it won't impede the user's progress on to other tasks (unless of course the text needs to be colored for the user to continue working...)
Being smarter than you look is always better than looking smarter than you are.
Posted

ok i know this isn't the approuch to go for on each keypress

i know only the last word entered has to be checked if it should to be colored but then again just try to make a simple syntax coloring control you'l soon see what i meen by flickering.

 

I am creating a syntaxcolntrol right now in vb.net and if you think you can do the syntax highlighting based on a richtextbox or even on a simple textbox please show me some code that dousn't

flicker while typing.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...