Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Richtextbox formatting

Posted on 2016-09-29
8
Medium Priority
?
99 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 45

Accepted Solution

by:
AndyAinscow earned 2000 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 45

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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 45

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 45

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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

926 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