473,508 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox and RTF?

24 New Member
Hi,

I have a paragraph of text, which i want to display to the user (possibly in a richtextbox). However, some words need to be in another colour.

I tried to use rtf, but when i use:
- richTextBox1.RTF = "my rtf string", the richTextBox1.RTF does not change (seems like this property is read-only!)
- richTextBox1.RTF.insert(index,string) again does not change the value of the rtf property.

So my question is:
1) How can I display text to the user in 2 different colours?
2) The user will then click on words displayed to him and I need to obtain a string of the word he clicked on (so obviously the control I use must be able to detect where the 'cursor' is)...

Any ideas?

thanks m8s!
Apr 2 '07 #1
1 1793
SammyB
807 Recognized Expert Contributor
> I tried to use rtf
Use the Text property
Expand|Select|Wrap|Line Numbers
  1. RichTextBox1.Text = "My RTF string"
> richTextBox1.RTF.insert(index,string)
Insert is tricky, it produces another string
Expand|Select|Wrap|Line Numbers
  1. RichTextBox1.Text = RichTextBox1.Text.Insert(2, " bigger")
> How can I display text to the user in 2 different colours?
Use SelectionColor property
Expand|Select|Wrap|Line Numbers
  1. RichTextBox1.SelectionStart = RichTextBox1.Find("bigger")
  2. RichTextBox1.SelectionColor = Color.Red
  3. RichTextBox1.SelectionStart = RichTextBox1.TextLength
>The user will then click on words displayed to him and I need to obtain a string of the word he clicked on
Use the SelectedText property
Expand|Select|Wrap|Line Numbers
  1. MsgBox("You selected: " & RichTextBox1.SelectedText)
Apr 2 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3213
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
3
21060
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
1
2469
by: Nathan Carroll | last post by:
In an mdi environment I constructed a child for with a richtextbox control that is used to load .rtf's. This works fine on the intiatial load of the form but when for is closed and reopened later...
12
2146
by: M O J O | last post by:
Hi, If I inside a thread creates a RichTextBox and only use this inside the thread, will there be any thread problems? I need to convert between Text and RTF inside a thread. Thanks!! M...
2
17267
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
11121
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
4838
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
3
7154
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...
0
2028
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
1
1695
by: bmerlover | last post by:
I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile...
0
7223
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,...
0
7114
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...
0
7377
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...
1
7034
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7488
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1544
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 ...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.