This is in reguards to my previous question.
I have a multiline RichTextBox and a ListBox filled with keywords.
When I type in the letter t, or any other first letter of a keyword
I would like the ListBox to show, just like it does in VB
The response to my last question helped tremendously, but
How can I make my selection the color Blue?
4 Replies - 1202 Views - Last Post: 18 January 2011 - 01:55 PM
#1
How do I make the selected text from a listbox the color blue?
Posted 17 January 2011 - 09:27 PM
Replies To: How do I make the selected text from a listbox the color blue?
#2
Re: How do I make the selected text from a listbox the color blue?
Posted 18 January 2011 - 07:15 AM
You will need to select the text you just added, look into selectionstart and selectionlength of the richtextbox. Then use Select() to hilight the text that selectionstart and selectionlength determined for selection, then use RTB.SelectionColor = Color.Blue
This post has been edited by CharlieMay: 18 January 2011 - 07:16 AM
#3
Re: How do I make the selected text from a listbox the color blue?
Posted 18 January 2011 - 08:20 AM
If your looking to change the listbox items color then use the Owner Draw Listbox.
#4
Re: How do I make the selected text from a listbox the color blue?
Posted 18 January 2011 - 01:42 PM
CharlieMay, on 18 January 2011 - 07:15 AM, said:
You will need to select the text you just added, look into selectionstart and selectionlength of the richtextbox. Then use Select() to hilight the text that selectionstart and selectionlength determined for selection, then use RTB.SelectionColor = Color.Blue
Thanks for the help, but I seem to get ALL of the text to change color and not just the keyword. I should know this using selectionstart and selectionlength but for some reason my mind seems "out there". I'm working on 3 different projects at the same time - almost, not a good idea I know. My listbox is VB Keywords in a txt file and I am attempting to create an editor that will color the Keywords Blue.
Thanks,
Steve
hawkvalley1, on 18 January 2011 - 08:20 AM, said:
If your looking to change the listbox items color then use the Owner Draw Listbox.
That looks like a good listbox, but,
My listbox is VB Keywords loaded from a txt file and I am attempting to create an editor that will color the Keywords Blue in the multiline textbox.
Thanks,
Steve
#5
Re: How do I make the selected text from a listbox the color blue?
Posted 18 January 2011 - 01:55 PM
The easiest way would be to enter the text into the RTB as I assume you're doing from the selection. Then since you can get the length of that keyword you know the selection length, The selection start is the RTB.TextLength - the length of the keyword. You could also use Find to find the keyword starting at an index of the textlength - the rtb.textlength.
There is a topic here where someone was doing something similar. I'll add the link if I can find it but basically the other method would be to scan the RTB and colorize found words that match a list of the words in your list.
Here's the link I was talking about. There is a lot of what you're doing in it and it may help you with other areas.
There is a topic here where someone was doing something similar. I'll add the link if I can find it but basically the other method would be to scan the RTB and colorize found words that match a list of the words in your list.
Here's the link I was talking about. There is a lot of what you're doing in it and it may help you with other areas.
This post has been edited by CharlieMay: 18 January 2011 - 02:23 PM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|