Page 1 of 1
print tutorial
#2
Posted 19 January 2007 - 03:52 PM
I will write you a tutorial on printing when I arrive back to my house.
#3
Posted 19 January 2007 - 03:54 PM
vbnet_noob, on Jan 19 2007, 03:02 PM, said:
hi,
I'd like to know about the print controls and how to use them.
thank you.
I'd like to know about the print controls and how to use them.
thank you.
MSDN's 101 VB Dot Net samples had a thing on it if you want to look at some code. I've attached the file to my post.
VB Dot Net's print controls are simple to use. They make use of system.drawing for just about everything, I myself know very little on the subject though.
#4
Posted 19 January 2007 - 04:32 PM
DeathKindler, the attachment didn't work. Here is the example from the 101 examples in .zip format.
Attached File(s)
-
Printing.zip (19.63K)
Number of downloads: 144
#6
Posted 20 January 2007 - 02:57 PM
vbnet_noob, on Jan 19 2007, 11:31 PM, said:
I have the 101 thing.
I'll have to go look at it tonight.
well it have print preview as well?
I'll have to go look at it tonight.
well it have print preview as well?
Yea, It will. Sorry about the broken attachment... my bad...
It'll have the actual printing and a print preview example in it, but its made mainly for text printing but you could get it to print a form or an image if you needed to.
#7
Posted 02 August 2007 - 10:41 AM
Vbnet_noob, what control are you trying to add a PrintPreview to?
#8
Posted 17 January 2008 - 08:53 AM
Hi, I am developing a report to be printed with PrintDocument class.The problem is some parts of this report are iterated and some not.In fact report consist of three sections.The top and buttom sections are always the same but middle section is being produced from Database.The problem is how to print more than one page, I tried to use HasMorePages but somehow I think I am doing something wrong.
I need to :
1-Print top and buttom sections more than one time if the data in middle section won't fit in its specified area.
2-Be able to access each new page, if possible.That way I can repeat itereated sections and write down the continued middle section.
3-Control the behaviour of HasMorePages in order to print middle section succefully.
Since this development is company-based the code I am gonna attach is protected.It cannot be used , distributed and altered under any circumstances.I am using the following code.
I'd apperciate any help.If you have more information about the code contact me directly.
Remember!This code snippet is protected by international laws.
I need to :
1-Print top and buttom sections more than one time if the data in middle section won't fit in its specified area.
2-Be able to access each new page, if possible.That way I can repeat itereated sections and write down the continued middle section.
3-Control the behaviour of HasMorePages in order to print middle section succefully.
Since this development is company-based the code I am gonna attach is protected.It cannot be used , distributed and altered under any circumstances.I am using the following code.
Code BlockWhile (intLastPrintedCell < strText.GetUpperBound(0))
e.HasMorePages = True
If Not intLastPrintedCell > 0 Then
Dim intDistance As Integer = 0
For i As Integer = strText.GetLowerBound(0) To strText.GetUpperBound(0)
If intDistance <= intSplit2Distance Then
text = strText(i)
If chkShowTextInBox.Checked = True Then
e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))
End If
rec.X = rea("FLEFT")
rec.Y = rea("FTOP") + intSplit1Distance + intDistance
rec.Height = rea("FHEIGHT")
rec.Width = rea("FWIDTH")
e.Graphics.DrawString(text, printFont, brsh, rec, frmt)
intDistance = intDistance + rec.Height + intFieldDistance
'e.HasMorePages = False
intLastPrintedCell = i
Else
'intLastPrintedCell = i
Exit For
'
End If
Next
Else
Dim intDistance As Integer = 0
For i As Integer = intLastPrintedCell To strText.GetUpperBound(0)
If intDistance < intSplit2Distance Then
text = strText(i)
If chkShowTextInBox.Checked = True Then
e.Graphics.DrawRectangle(Pens.Black, rea("FLEFT"), rea("FTOP") + intSplit1Distance, rea("FWIDTH"), rea("FHEIGHT"))
End If
rec.X = rea("FLEFT")
rec.Y = rea("FTOP") + intSplit1Distance + intDistance
rec.Height = rea("FHEIGHT")
rec.Width = rea("FWIDTH")
e.Graphics.DrawString(text, printFont, brsh, rec, frmt)
intDistance = intDistance + rec.Height + intFieldDistance
'e.HasMorePages = False
intLastPrintedCell = i
Else
'e.HasMorePages = True
'intLastPrintedCell = i + 1
'
End If
Next
End If
End While
e.HasMorePages = FalseI'd apperciate any help.If you have more information about the code contact me directly.
Remember!This code snippet is protected by international laws.
#9
Posted 14 June 2008 - 11:23 AM
To Print the entire form
Add a Button, PrintForm Controls
Double Click the Button and add the following code.
I think this works, it did for me, it depends what version of VB you use i think. Due to experiences.
CS
Add a Button, PrintForm Controls
Double Click the Button and add the following code.
dim reply
reply = MsgBox("Do you really want to PRINT?", 52)
Rem 52 is made up of 4 for Yes/No and 48 for the exclamation mark icon
If reply = 6 Then
PrintForm1.Print()
End IfI think this works, it did for me, it depends what version of VB you use i think. Due to experiences.
CS
Conor Steel
#10
Posted 14 June 2008 - 02:09 PM
You can get rid of a variable and two lines by writing:
Also, you generally should not be cryptic; better to err on the other side:
And I don't prefer this because it's longer, but you could also use the main message box function:
If MsgBox("Do you really want to PRINT?", 52) = 6 Then PrintForm1.Print()Also, you generally should not be cryptic; better to err on the other side:
If MsgBox("Do you really want to PRINT?", MsgBoxStyle.YesNo Or MsgBoxStyle.Exclamation) = MsgBoxResult.Yes Then PrintForm1.Print()And I don't prefer this because it's longer, but you could also use the main message box function:
If MessageBox.Show("Do you really want to PRINT?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then PrintForm1.Print()
#14
Posted 31 March 2009 - 03:40 PM
Hi
Im looking for some kind of tutorial aswell..
Its about making a very simple program, that can copy 4 textboxes of text on a label(5x8cm) and then be printed by a old labelprinter i just got..
Another thing, can you even make these printing things in VB2008 express?
Im looking for some kind of tutorial aswell..
Its about making a very simple program, that can copy 4 textboxes of text on a label(5x8cm) and then be printed by a old labelprinter i just got..
Another thing, can you even make these printing things in VB2008 express?
Page 1 of 1

Sign In
Register
Help


MultiQuote



