Solved

Resetting RichTextBox after loading RTF

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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

717 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