| | |
Print the contents of RichTextBox
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2009
Posts: 3
Reputation:
Solved Threads: 0
I have a form with one richtext box. This rtb has different formats for each line i.e., some text is in bold letters, some center aligned. Currently I am using the PrintDialog Box to print the contents of the rtb and Print Preview DialogBox to preview the contents. The problem is when I preview the contents I see everything left aligned and in common font for all the text.
Could someone please tell me how to print the contents of the RichTextBox with different formats.
This is how my code looks :
Could someone please tell me how to print the contents of the RichTextBox with different formats.
This is how my code looks :
VB.NET Syntax (Toggle Plain Text)
Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click Dim Print_Dialog As New PrintDialog Print_Dialog.Document = PreparePrintDocument() Print_Dialog.ShowDialog() If Print_Dialog.ShowDialog = Windows.Forms.DialogResult.OK Then Print_Dialog.Document.Print() End If End Sub Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click Dim Print_Preview As New PrintPreviewDialog Print_Preview.Document = PreparePrintDocument() Print_Preview.WindowState = FormWindowState.Maximized Print_Preview.ShowDialog() End Sub Private Function PreparePrintDocument() As PrintDocument Dim Print_Document As New PrintDocument AddHandler Print_Document.PrintPage, AddressOf Print_PrintPage Return Print_Document End Function Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Dim Page As String Page = Me.Rtbbill.Text e.Graphics.DrawString(Page, Rtbbill.Font, Brushes.Black, 50, 50) e.HasMorePages = False End Sub
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Try this site:
http://msdn.microsoft.com/en-us/library/ms996492.aspx
http://msdn.microsoft.com/en-us/library/ms996492.aspx
Wayne
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
![]() |
Similar Threads
- Print contents in richTextBox (C++)
- Visual C++ 2008 - Printing Richtextbox control (C++)
- Need to implemnt the RTF print in application (VB.NET)
- Using a control to just call the subroutine (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Back Up
- Next Thread: Cut Paste functionality to grid view
| Thread Tools | Search this Thread |
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click code combo cpu cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic employees excel exists fade filter forms generatetags html images input intel internet listview map mobile module monitor msaccess mysql net number objects open pan panel pdf picturebox picturebox2 port position print printing printpreview problem regex reuse right-to-left save search searchvb.net serial settings shutdown socket sqldatbase sqlserver storedprocedure survey temperature textbox timer timespan transparency txttoxmlconverter user usercontol vb vb.net vba vbnet vista visual visualbasic visualbasic.net visualstudio.net web winforms wpf wrapingcode xml year





