473,513 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox.SelectionColor not taking effect

Hello.

Ive got a form with one richtextbox object called outputBox. When I
click a button on the form that calls some other things to happen one
of those things is setting the outputBox.SelectionColor to a new color
other than the default forecolor of the outputBox.

When I do this, from reading MSDN's explanation, I am under the
assumption that new text entered after this point will be of that
color until I change it to something else or back to the forecolor
default. This does not occur. the text remains the same color as the
objects forecolor value. I've removed the forecolor values and still
have had no luck. Below is an example of what I'm doing.

this.outputBox.SelectionColor = Color.Yellow;
this.outputBox.Text += "blah blah blah";
this.outputBox.SelectionColor = Color.White;

The blah blah blah text remains white and for the life of me I cant
figure it out hehe. Any ideas on what I'm doing wrong?

-Buht
Nov 16 '05 #1
1 5524
buht <bu******@gmail.com> wrote:
this.outputBox.Text += "blah blah blah";


Use:

this.outputBox.SelectedText = "blah blah blah";

You may want to set SelectionStart first; i.e.:

this.outputBox.SelectionStart = this.outputBox.TextLength;
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
658
by: Juan | last post by:
I`m inserting strings in a rich text control using the AppendText method, I would like to change certain parts of the string so, for example, a certain word appears bold and red when inserted. Is it possible using this control? Thanks, Juan.
2
5828
by: Alan | last post by:
Hi all, I want to hilight some syntax keywords. While parsing text, I used these properties such as SelectionStart,SelectionLength and SelectionColor of RichTextBox. Although the syntaxhilghting effect was reached, I found original undo/redo function didn't work!! Any ideas? Thanks,
0
2072
by: y2k692hu | last post by:
Hello I am trying to run this and I keep getting a "SystemNullReferenceException: Object reference not set to instance of an object" error. I have three menu items bold, italic and underline. When i select the text in my RichTextBox, in order to format it bold, italic or underline, I get that error. The debugger points to my Private Sub...
1
1208
by: Lespaul36 | last post by:
I am writing lan chat program and want the messages to be color coded for sent/recieved...you know the standard idea. I cannot seem to get the richtextbox to keep the color. I do a recieve and it is fine, I do a send and it is fine, another recieve and all of the text becomes one color. Here is the code I am using for the the Recieve..I...
5
1479
by: Ludwig | last post by:
Goal: text that is pasted in a RichTextBox control has to be formatted (keywords should get another forecolor/style). My first attempt to format the text was the traditional approach of setting SelectionStart and SelectionLength, and then setting the SelectionColor/SelectionFont. This works fine for small updates, but when large amount of...
3
7156
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to just add plain (e.g.. rtf.Text += "new stuff..."; ) but some text, when added, I want to be in a different color or font size. Find() will not...
8
2579
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have created a Control that extends RichTextBox to do syntax-hilighting. My strategy is to have a timer that restarts every time a user types a key so that it can wait until the user pauses for at least 500 milliseconds, then perform its work. The hilighting simply goes through a list of keywords, finding each instance in the RichTextBox,...
0
3425
by: shivaranjaniadimulam21 | last post by:
Hello, I need to implement an email editor control in my application. The control should allow me to type in text in any format,font etc. This i have managed using the richtextbox control available with .NET. As the email textbox can include the embedded images I want to provide this functionality in it. Now the next stuff is I want to...
0
2529
by: dannyboy1990 | last post by:
I've been developing in vb.net for a few months now, well since i left school and one of my projects for my current company is to create a sql tool which is used on a daily basis to update, delete and select from the database. One of the functions i want this program to do is to highlight all sql words to make the program look alot 'cleaner'. ...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.