YZlat
asked on
Text formatting inside a RichTextox control
On my windows form I have two RichtextBox controls displaying a large amount of text. i want to format some of the words, making them bold, and for some changing font color or size for a paragraph. How can I do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.codeproject.com/KB/cs/RTFSyntaxColour.aspx
http://latex2rtf.sourceforge.net/rtfspec_7.html#rtfspec_18
These URL's have required info.
http://latex2rtf.sourceforge.net/rtfspec_7.html#rtfspec_18
These URL's have required info.
ASKER
To be honest thos links were not helpful. Too much stuff to go through and I still didn't find anything there. I found some stuff here http://www.pindari.com/rtf1.html
Could you help me with creating a hyperlink in richtextbox?
something equivalent to <a href="http://www.google.com">goole</a>
Could you help me with creating a hyperlink in richtextbox?
something equivalent to <a href="http://www.google.com">goole</a>
set the DetectUrls property to true. This should create Hyperlink as soon as you enter some text with http:// and will open with your default browser.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace WindowsFormsApplication1 {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void richTextBox1_LinkClicked(object sender, LinkClickedEventArgs e) {
Process.Start(e.LinkText);
}
}
}
ASKER
The thing is, I set the text of the RichTextBox the following way:
RichTextBox1.Rtf="{...... http://www.google.com .....}";
How do I make http://www.google.com to show up as hyperlink? No one enters the text into textbox, in fact, it is read-only
RichTextBox1.Rtf="{...... http://www.google.com .....}";
How do I make http://www.google.com to show up as hyperlink? No one enters the text into textbox, in fact, it is read-only
Here I made this text as read only and when you hit on the Text Press Here it will be re-directed to google.com as your application needs. You can use that piece of code and modify the text lable.
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
Process.Start("http://www.google.com");
MessageBox.Show("Press here!");
}
private void Form1_Load(object sender, EventArgs e)
{
linkLabel1.Text = "Press Here";
linkLabel1.AutoSize = true;
linkLabel1.Location = this.richTextBox1.GetPositionFromCharIndex(this.richTextBox1.TextLength);
this.richTextBox1.Controls.Add(linkLabel1);
this.richTextBox1.AppendText(linkLabel1.Text + " ");
this.richTextBox1.SelectionStart = this.richTextBox1.TextLength;
}
ASKER
Thanks for your help but my question was not answered completely
ASKER
I tired using \u \u0 but didn't work