Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Resetting RichTextBox after loading RTF

Posted on 1998-09-28
4
Medium Priority
?
167 Views
Last Modified: 2010-04-30
Dear Guys (and Gals),

         I have one question which might sound simple to you but I still can't find the solution to it.

      I have got a rich text box which will load a RTF file from local drive.  After which the user can also choose to clear it and type in their own message. However, I realised that even if I do a

      richtextbox1.text = ""

      The previous settings for the fonts and the colors still stay in the box. This is really annoying as if the previous document contains underline and say green color for example, I won't be able to clear that for the user. Can I do a select everything in the richtextbox1 and then set the selcolor, selbold, selfontname etc to something I like?

      I find that as richtextbix do not have a Forecolor property I cannot change its color unless I select all the text in the rich text box.

      If it is not too much to ask, can you please kindly shed some light on this matter?

      Thanks a million.

0
Comment
Question by:happysam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1437038
do :
richtextbox1.TextRtf = "" 
0
 
LVL 3

Expert Comment

by:HATCHET
ID: 1437039
happysam,

waty's answer will leave some of the fonts and fontstyles in place which is what you're trying to fix.  Use the following code instead.  It will change everything back to the default fonts.  

  RichTextBox1.SelStart = 0
  RichTextBox1.SelLength = Len(RichTextBox1.Text)
  RichTextBox1.SelBold = False
  RichTextBox1.SelItalic = False
  RichTextBox1.SelUnderline = False
  RichTextBox1.SelColor = &H0&
  RichTextBox1.SelFontName = "MS Sans Serif"
  RichTextBox1.SelFontSize = 8
  RichTextBox1.Text = ""


HATCHET
0
 

Author Comment

by:happysam
ID: 1437040
Dear HATCHET,

     It works! It really works! Such a simple solution yet I was trying it out for 2 days! Simple yet elegent!

     Thanks a lot HATCHET!  :)

Regards,
Happy
0
 
LVL 3

Accepted Solution

by:
HATCHET earned 120 total points
ID: 1437041
happysam,

Thank You.    =)     <Takes a bow...>
How about a few points?   ; P
Take Care,


HATCHET
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

618 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