• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

Looking for the right control.

Hi,

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.

Jim


0
syntel
Asked:
syntel
  • 3
  • 2
  • 2
  • +3
1 Solution
 
gencrossCommented:
The standard textbox supports all of the above things you mentioned...

Examples...

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

Hope this helps.
0
 
sodakotahuskerCommented:
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.  

 
0
 
RYMENHOUTCommented:
WHY NOT TRY THE VBACCELERATOR RTF BOX
WWW.VBACCELERATOR.COM
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rspahitzCommented:
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
0
 
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.
0
 
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?

Thanks,

Jim
0
 
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.
0
 
rspahitzCommented:
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.
0
 
syntelAuthor Commented:
Thanks all.  I will probably go with the picbox.

Thanks again,

Jim
0
 
syntelAuthor Commented:
Anyone know if the RichTextBox can do lines?  The PictureBox does - what about the RTB?  
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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