Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Printing a String on Paper 1

Status
Not open for further replies.

UncleCake

Technical User
Feb 4, 2002
355
0
0
US
Hi, I am very new to VB.Net, but pretty experienced in VB6. I need to print an item number on paper in VB.Net, but I am having a lot of problems sorting through all of the examples on the net to just do a basic print string.

In the past (VB6) I have given the X and Y coordinates, the string and I am off. I assume that it isn't that easy in VB.Net.

Are there any examples out there that are totally basic (like Hello World) tutorial that would help me through my first printing project?

-Uncle Cake
 
Drag and drop a PrintDocument from the toolbox. Double click it and use: e.graphics.drawstring()

An example could be:
Code:
' Create the font
Dim Font1 As New Font("Comic Sans MS", 12, FontStyle.Underline Or FontStyle.Bold)

Dim myString as String = "This string will be printed!"
e.Graphics.DrawString(myString, Font1, Brushes.Red, x, y)

So, You pass the to be printed string, then the font you want, then the color and last x & y coordinates.
You may also want your string to be wrapped, so have a look at Dim r as new rectangle(...). This rectangle will not e printed, you just use it to fit in it some text.

Hope this short info helps
 
Thanks TipGiver, that got me off to a start, but I can't figure out how to call the PrintDocument1_PrintPage.

-Uncle Cake
 
I figured it out. Thanks for your help!

-Uncle Cake
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top