To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
VBForums  

VB Wire News
MSDN Subscribers: Download the VS 2010 Release Candidate
MSDN Subscribers: Download the VS 2010 Release Candidate
Sell Your Code and Make Money?
Creating your own Tetris game using VB.NET
Article :: Improving Software Economics, Part 4 of 7: Top 10 Principles of Iterative Software Management



Go Back   VBForums > Visual Basic > Visual Basic .NET

Reply Post New Thread
 
Thread Tools Search this Thread Display Modes
Old May 13th, 2007, 04:20 PM   #1
DamianC
New Member
 
Join Date: May 07
Location: Arnhem, the Netherlands
Posts: 5
DamianC is an unknown quantity at this point (<10)
How to print the contents of a Richtextbox and a normal textbox on one page?

Hi all,

I know how to print the contents of a Richtextbox (see the RichTextBoxPrintCtrl control, http://support.microsoft.com/kb/811401), but on this way the contents of the Richtextbox is treated as one completed document, in other words, after the contents has been printed, the page is ejected from the printer. Even if the Richtextbox contains only one line of text or only one small picture, the page is ejected.

I want to print the contents of a Richtextbox, followed by some regular text (e.g. from a normal textbox), on one page.

Or: Print first regular text, then a Richtextbox, then regular text, then a Richtextbox on one page.

Anyone know how to do this? I'm programming in VB.NET, 2005.
Help is greatly appreciated.
Thanks in advance.
DamianC is offline   Reply With Quote
Old May 26th, 2007, 10:04 AM   #2
.paul.
PowerPoster
 
Join Date: May 07
Location: Chelmsford UK
Posts: 6,080
.paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+).paul. is a splendid one to behold (700+)
Re: How to print the contents of a Richtextbox and a normal textbox on one page?

simple printing example: combine this + ms example, you'll have what you want:


Imports System.Drawing.Printing
Public Class PrintTest
Inherits System.Windows.Forms.Form

Private Sub cmdPrint_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles cmdPrint.Click

' Create the document and attach an event handler.
Dim MyDoc As New PrintDocument()
AddHandler MyDoc.PrintPage, AddressOf MyDoc_PrintPage

' Allow the user to choose a printer and specify other settings.
Dim dlgSettings As New PrintDialog()
dlgSettings.Document = MyDoc
Dim Result As DialogResult = dlgSettings.ShowDialog()

' If the user clicked OK, print the document.
If Result = DialogResult.OK Then
' This method returns immediately, before the print job starts.
' The PrintPage event will fire asynchronously.
MyDoc.Print()
End If

End Sub

Private Sub MyDoc_PrintPage(ByVal sender As Object, _
ByVal e As PrintPageEventArgs)


' Define the font.
Dim MyFont As New Font("Arial", 30)

' Determine the position on the page.
' In this case, we read the margin settings
' (although there is nothing that prevents your code
' from going outside the margin bounds.)
Dim x As Single = e.MarginBounds.Left
Dim y As Single = e.MarginBounds.Top

' Determine the height of a line (based on the font used).
Dim LineHeight As Single = MyFont.GetHeight(e.Graphics)

' Print five lines of text.
Dim i As Integer
For i = 0 To 4
' Draw the text with a black brush,
' using the font and coordinates we have determined.
e.Graphics.DrawString("This is line " & i.ToString(), MyFont, Brushes.Black, x, y)

' Move down the equivalent spacing of one line.
y += LineHeight
Next
y += LineHeight

' Draw an image.
e.Graphics.DrawImage(Image.FromFile(Application.StartupPath & "\test.bmp"), x, y)

End Sub


End Class
.paul. is offline   Reply With Quote
Old Jun 4th, 2007, 04:28 PM   #3
DamianC
New Member
 
Join Date: May 07
Location: Arnhem, the Netherlands
Posts: 5
DamianC is an unknown quantity at this point (<10)
Re: How to print the contents of a Richtextbox and a normal textbox on one page?

Thanks .Paul., I'll try this.
I'm not too familiar yet with these handler things and so, but your code looks OK.
DamianC is offline   Reply With Quote
Reply

Go Back   VBForums > Visual Basic > Visual Basic .NET


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:39 AM.




To view more projects, click here

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.