 |
 |

02-13-2010, 07:20 AM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
Visual Basic - Notepad ++ text colors
|
is there a way in Visual Basic 2008 to do so if i type in a rich text box it will make some thing like this
i am here
i was here
whit the colors in 1 box
hope i get some help here!
thanks
|
|

02-14-2010, 05:29 AM
|
|
Privileges Suspended
|
|
Join Date: Feb 2010
Location: Canada
Posts: 101
|
|
richtextbox color
|
Try typing in the name of the RichTextBox and then put a period after it and you should come up with a lot of options for what you can do with that RichTextBox.
Example:
RichTextBox1.
See if there is one in the list called "ForeColor" and use that:
RichTextBox1.ForeColor = Color.Blue
- Andorsay
|
|

02-14-2010, 07:17 AM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
|
what do you mean ? can you give me some kind of code that will show if i did type 1234 in the richtextbox then it will put a color on it
like
Richtextbox1.text = ("bla bla bla 1234 bla bla bla")
|
|

02-14-2010, 07:28 AM
|
|
Privileges Suspended
|
|
Join Date: Feb 2010
Location: Canada
Posts: 101
|
|
Try This...
|
RichTextBox1.ForeColor = Color.Blue
RichTextBox1.Text = "bla bla bla"
Try that. Is the color of the text Blue?
or try...
RichTextBox1.ForeColor = Color.Blue
RichTextBox1.Text = "bla bla bla"
RichTextBox1.ForeColor = Color.Red
RichTextBox1.Text = RichTextBox1.Text & " bla bla bla"
- Andorsay
|
|

02-14-2010, 07:43 AM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
|
Dosent work!
it just set all the text in the box to red/blue and just auto type bla bla bla and when i type something it just add it agin
any way else?
|
|

02-14-2010, 12:00 PM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
|
Need help still
Some one out there HELP ME
|
|

02-14-2010, 01:32 PM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,885
|
|
|
Have a look at the SelText, SelPos, SelLen property of the RTB control
For the VB6 version of the RichTextBox control that is. Your question is about VB.Net, so moved the thread to the appropriate forum
|
|

02-14-2010, 01:57 PM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
|
I dont understand what you mean 100% something **** select. someting and thanks for moving it
and i know the RGB thing
|
|

02-14-2010, 05:14 PM
|
 |
Fabulous Florist
Forum Leader * Guru *
|
|
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
|
|
|
RichTextBox was designed to edit rich text. Not so much to make a highlighting text editor.
Let's say you have the text "Hello" and you want to make it blue. First, you have to set the SelectionStart property to 0. This moves the cursor to before the "H". Next, you set the SelectionLength property to "5". That is the length of the word, so "Hello" will be highlighted. Finally, you set the SelectionColor property to blue. This sets the highlighted text to blue. Optionally, you'd then set SelectionStart and SelectionLength to what they were before you started highlighting.
If you want to highlight all of the text in the box, you have to do this for each line. The Lines property is a collection where each element represents a line of the text. The GetFirstCharIndexFromLine() method can tell you what the value for SelectionStart needs to be for each line.
Once you get past about 10 lines of text, this process is slow and has tons of flicker. I've had a lot of trouble with it keeping the cursor in the right place in the past. There's no way around it for the RichTextBox; if you want to make a highlighting text editor like Notepad++ then you'll get better results if you look for a third-party control.
|
|

02-14-2010, 07:45 PM
|
|
Junior Contributor
|
|
Join Date: May 2008
Posts: 300
|
|
Quote:
Originally Posted by AtmaWeapon
Once you get past about 10 lines of text, this process is slow and has tons of flicker. I've had a lot of trouble with it keeping the cursor in the right place in the past. There's no way around it for the RichTextBox; if you want to make a highlighting text editor like Notepad++ then you'll get better results if you look for a third-party control.
|
You can get decent results if you edit the RTF manually, however you might run into problems because RTF uses a color table at the beginning of the document (something like "\r255\g0\b255"), and if you have to do twenty or thirty different colors it will get bulky fairly fast.
|
|

02-15-2010, 02:00 AM
|
|
Newcomer
|
|
Join Date: Feb 2010
Posts: 14
|
|
|
Thanks guys, this realy helped me!
i want to take the time it takes!
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|