Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Visual Basic - Notepad ++ text colors


Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2010, 07:20 AM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Question 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
Reply With Quote
  #2  
Old 02-14-2010, 05:29 AM
Andorsay Andorsay is offline
Privileges Suspended
 
Join Date: Feb 2010
Location: Canada
Posts: 101
Cool 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
Reply With Quote
  #3  
Old 02-14-2010, 07:17 AM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Default

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")
Reply With Quote
  #4  
Old 02-14-2010, 07:28 AM
Andorsay Andorsay is offline
Privileges Suspended
 
Join Date: Feb 2010
Location: Canada
Posts: 101
Cool 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
Reply With Quote
  #5  
Old 02-14-2010, 07:43 AM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Default

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?
Reply With Quote
  #6  
Old 02-14-2010, 12:00 PM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Default

Need help still
Some one out there HELP ME
Reply With Quote
  #7  
Old 02-14-2010, 01:32 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

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
Reply With Quote
  #8  
Old 02-14-2010, 01:57 PM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Default

I dont understand what you mean 100% something **** select. someting and thanks for moving it

and i know the RGB thing
Reply With Quote
  #9  
Old 02-14-2010, 05:14 PM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is online now
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,416
Default

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.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #10  
Old 02-14-2010, 07:45 PM
Eradicator Eradicator is offline
Junior Contributor
 
Join Date: May 2008
Posts: 300
Default

Quote:
Originally Posted by AtmaWeapon View Post
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.
Reply With Quote
  #11  
Old 02-15-2010, 02:00 AM
Iversen Iversen is offline
Newcomer
 
Join Date: Feb 2010
Posts: 14
Default

Thanks guys, this realy helped me!

i want to take the time it takes!
Reply With Quote
Reply

Tags
basic, colors, notepad, visual


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->