Solved

Resetting RichTextBox after loading RTF

Posted on 1998-09-28
4
157 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
  • 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

708 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

18 Experts available now in Live!

Get 1:1 Help Now