Solved

Resetting RichTextBox after loading RTF

Posted on 1998-09-28
4
161 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 30 total points
ID: 1437041
happysam,

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


HATCHET
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

740 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