Looking for the right control.


I need a control that I can use to display text with some formatting, e.g. text placement, bolding, etc.  The Rich Text control would do the job, I would think but I would prefer something more light weight.  

I know that the Picturebox control can display text but MSDN has very little info on this method, in fact it's not even listed under methods despite the fact that MSDN makes reference to the method.

I also will need to print the text displayed in whatever control I use.

Any ideas are appreciated.


Who is Participating?

Improve company productivity with a Business Account.Sign Up

sodakotahuskerConnect With a Mentor Commented:
You are right but I bet he wants selective bolding/coloring etc which requires something like rich text box because of its use of rtf formatting.  You can use print method on a picturebox to print multiple font types but it is not real easy since you have to control the entry point for the text.   Here is a sample:

Private Sub Form_Activate()
    Picture1.CurrentX = 500
    Picture1.CurrentY = 900
    Picture1.FontBold = True
    Picture1.ForeColor = vbGreen
    Picture1.Print "This is quite tedious"
    Picture1.CurrentX = 1500
    Picture1.CurrentY = 1900
    Picture1.FontItalic = True
    Picture1.ForeColor = vbRed
    Picture1.FontSize = 22
    Picture1.Print "Whatever "

End Sub

I use the richtext box control myself.  

The standard textbox supports all of the above things you mentioned...


With Text1
   .Alignment = 0 'left
   .Alignment = 1 'right
   .Alignment = 2 'center
   .FontBold = True
   .FontSize = 14
   .ForeColor = vbRed
End With

Hope this helps.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I think sodakotahusker's got it, but understand that the picturebox is pretty heavyweight and also won't allow users to select the text.

However, you could make the task less tedious by creating a subroutine for it:

Private sub PrintText(TextToPrint as string, optional XPosition as double=-1, optional YPosition as double=-1, optional TextColor as long=-1, optional FontSize as single =0, optional MakeBold as boolean=false, optional MakeItalic as boolean=false)

if XPosition <> -1 then
  Picture1.CurrentX = XPosition
end if

if YPosition <> -1 then
  Picture1.CurrentY = YPosition
end if

if TextColor <> -1 then
  Picture1.Forecolor = TextColor
end if

if FontSize <> 0 then
  Picture1.Font.Size = FontSize
end if

Picture1.Font.Bold = MakeBold
Picture1.Font.Italic = makeItalic

Picture1.Print TextToPrint;
end sub

' Now this is more manageable
Private Sub Form_Activate()
   PrintText "This is quite tedious", 500, 900, vbGreen, , True
   PrintText "Whatever ", 1500, 1900, vbRed, 22, , True
End Sub
Richie_SimonettiIT OperationsCommented:
I recommend you that stick with Richtextbox. If we need great funcionality, we must "pay" for it.
There is a thin line between performance, easy to use, memory usage, disk space, etc.
We have to decide if it worth.
syntelAuthor Commented:
Thanks for the replies!

I do want selective bolding, color, etc, but I only need to display the text and print it.

How much 'weight' does the Richtextbox use as compared to the picturebox?  I did not find the examples of the Print method in MSDN - did I miss it?


Richie_SimonettiIT OperationsCommented:
did you think to show formatted plain text using HTML?
Webbrowser is huge (i know that!) but it is in almost every OS Windows on this planet.
The Print command is not in MSDN because it is a "straggler" from the days of QuickBASIC and MS wasn't sure exactly how to support it in the first VB iteration.  They continued to support it by having the window (and also picturebox) become the print area, but apparently decided that it's better supported by dropping objects at the desired places.

As for weight, I think that the RichTextBox is a spin-off of the picturebox and has since had additional features added that made it "heavier."  The reason it's hard to tell is because although the RichTextBox is a separate component (RICHTX32.OCX) at 200K, the PictureBox is part of the standard VB package which includes many other controls and the VBA engine (MSVBVM60.dll) at 1356K.
syntelAuthor Commented:
Thanks all.  I will probably go with the picbox.

Thanks again,

syntelAuthor Commented:
Anyone know if the RichTextBox can do lines?  The PictureBox does - what about the RTB?  
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.