Solved

Richtextbox formatting

Posted on 2016-09-29
8
21 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
 
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now