Solved

Looking for the right control.

Posted on 2002-05-08
10
243 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Excel: fill / replace values based on a config sheet. 5 61
vba find the last empty column 10 88
Excel VBA combine two working workbooks 8 47
Copy a row 12 58
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now