[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

RichTextBox 6.0 won't display my formatting

I'm not adding an editor to my program, or allowing the user to enter any text at all. All I want to do is display some premade RTF Help files in RichTextBoxes when the program loads.

I have added the Microsoft RichTextBox 6.0 Control to my program... I added a RichTextBox to my form and then I tried out a line from a tutorial I found:

    Dim sRTF As String
    sRTF = “{{\colortbl;\red255\green0\blue0;} Visual {\cf1 Basic} Rules!}”
    RichTextBox1.TextRTF = sRTF

But when my form loads the word "Basic" is not red.

I also tried making an RTF file with a variety of formatting options, saved it, then ran the line:

    RichTextBox1.LoadFile "C:\test.rtf", 0

But when it loads up, everything is plain text except for the bullet points, those seem to come through fine, but nothing is Bold, Underlined, different font size, or different colors.

I can go in after the fact and apply formatting to the text in the RTF box, but if I premake a file and try to load it in, the bullet points are the only thing it recognizes.

I don't understand what I might be doing wrong here. I assumed the simple line from the tutorial would at least work where my more involved files failed, but I can't even get that to display properly.

Any ideas what I might be doing wrong here?
0
kkonkle
Asked:
kkonkle
  • 2
  • 2
1 Solution
 
hesCommented:
This works for me

sRTF = "{{\colortbl;\red255\green0\blue0;} Visual {\cf1 Basic} Rules!}"
(double quotes on each end)
0
 
kkonkleAuthor Commented:
Sorry, I'm not sure what those are in my post above, but they should be double quotes.

The line you supplied is exactly what I have in my program, yet it does not display properly.

I should add, if I make a new project, and use either method as above, it works great, all formatting comes through.  If I do everything exactly the same in my existing program, only the bullet points are displayed properly.

In the existing project the RichTextBox exists inside an SStab control, which is on a child form embedded into an MDIform.  I wouldn't think the controls containing the RichTextBox would matter, but for all I know they might.

Let me know what else you need to know about the existing project I'm trying to insert this into.
0
 
kkonkleAuthor Commented:
OK, lately it seems like I always spend my points on questions and then figure them out myself.  

So here's the scoop on this one.

Right now my program starts up and runs things in this order:

MDIform_Load
   Child1_Load
      ...
   End Child1_Load
   Child2_Load
      AAA
   End Child2_Load

   ...

   Child9_Load
      ...
   End Child9_Load

   BBB
End MDIform_Load

Previously, I was putting the RichTextBox code within the Child2_Load section, where the AAA appears above... apparently VB doesn't like this.  When I move the exact same code to where the BBB is, at the very end of the MIDform_Load event, the formatting comes through just fine.  

So that's the answer.  I guess I'd like to request my points back.
0
 
hesCommented:
Post a new question at
http://www.experts-exchange.com/Community_Support/
Stating you have solved the question yourself,
with a link back to this question, a moderator will take care of that for you.
0
 
DarthModCommented:
PAQd, 125 points refunded.

DarthMod
CS Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now