Solved

Richtextbox formatting

Posted on 2016-09-29
8
25 Views
Last Modified: 2016-09-29
Hello,
How can I format text in the richtextbox.
I am using vb.net 2014 windows.

Need to make text bold and change font on some words.
Cheers
0
Comment
Question by:RIAS
  • 4
  • 4
8 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 41821420
https://msdn.microsoft.com/en-us/library/0dhsw8eb(v=vs.90).aspx

richTextBox1.Rtf = @"{\rtf1\ansi This text is in \b bold\b0, " +
@"this is in \i italics\i0, " +
@"and this is \ul underlined\ul0.}";

For VB the actual string is the same
0
 

Author Comment

by:RIAS
ID: 41821423
Andy,
Where do I add  this code?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41821430
Also look at
https://en.wikipedia.org/wiki/Rich_Text_Format

There is an example where the font is specified.

ps.  Rtf format AFAIK isn't going to be further developed, it seems like HTML formats are replacing it.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41821433
>>Where do I add  this code?

eg. FormLoad event, the rtf textbox needs to have been created when you specify the formatted text.  Note you need to use the Rtf property not the Text property.  The Rtf displays the formatted text according to the string, the Text property just treats it as a string without displaying any formatting.
0
 

Author Closing Comment

by:RIAS
ID: 41821438
Cheers mate!
0
 

Author Comment

by:RIAS
ID: 41821449
Andy,
How can I add new line and a picture to it?
Cheers
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41821496
New line is \r\n
Picture - I don't know offhand.  What you could do is open winword, put a picture in then save the document as rtf.  Inspect the file you saved with notepad (which does not format the file in the editor window).
1
 

Author Comment

by:RIAS
ID: 41821534
Cool Andy ,will try!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question