×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Display text in picture box

Display text in picture box

Display text in picture box

(OP)
I use a plain form to draw a picture using Line and Circle.  How can I put text in the same form without using a text box?  The problem with a text box is that when you re-size the form when running the program, the text box stays in the same absolute location and either disappears or obscures some of the drawing depending on what proportions the window is re-sized to.  Re-sizing is necessary.

RE: Display text in picture box

To write text directly on the picturebox you use the currentx and currenty properties and the print method. For example:
picturebox.currentx=<x coordinate for text>
picturebox.currenty=<y coordinate for text>
picturebox.print "add your string here"

You may have a similar problem when using this approach as the text will stay in the same place in the picturebox when you resize the form (unless you code it to do otherwise). You could add code to the resize event to move the text (this will work whether you are using the text box or text directly on the picturebox).

RE: Display text in picture box

(OP)
cowski -
Thanks - it worked just fine.
You get a star.
Questions:
1)How do I change the text height?
2)How do I make the text right or center justified?

RE: Display text in picture box

Glad that I could be of help.

To change the text height use picturebox.font.size = 14 'text size in points.

You can also change the font with picturebox.font.name = "font name". You will want to be careful about changing the font though, because it is possible that not everyone will have the font you want to use. If the specified font is missing the system will substitute, but the substitute may not be desirable.

As for the justification options (I hope I'm wrong but...) I think you'll have to take care of those yourself in code. I do know that there are functions that will return the length of the text string (actual physical length, not number of characters) taking into account the font size and character spacing. I don't remember the names of these functions offhand but when you find them you can use them to determine where to place currentx and currenty to get the desired justification.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close