Solved

Looking for the right control.

Posted on 2002-05-08
10
261 Views
Last Modified: 2011-08-18
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
Comment
Question by:syntel
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 4

Expert Comment

by:gencross
ID: 6997212
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
 
LVL 1

Accepted Solution

by:
sodakotahusker earned 100 total points
ID: 6997253
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
 

Expert Comment

by:RYMENHOUT
ID: 6997356
WHY NOT TRY THE VBACCELERATOR RTF BOX
WWW.VBACCELERATOR.COM
0
Industry Leaders: 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!

 
LVL 22

Expert Comment

by:rspahitz
ID: 6997574
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6997644
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
 

Author Comment

by:syntel
ID: 6998233
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6998679
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
 
LVL 22

Expert Comment

by:rspahitz
ID: 6999193
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
 

Author Comment

by:syntel
ID: 7000413
Thanks all.  I will probably go with the picbox.

Thanks again,

Jim
0
 

Author Comment

by:syntel
ID: 7000994
Anyone know if the RichTextBox can do lines?  The PictureBox does - what about the RTB?  
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

735 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