| | |
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 |
"crystal .net .net2005 30minutes 2008 access add application arithmetic array assignment basic binary box button buttons center click code combo combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net employees excel exists firewall folder image images isnumericfuntioncall login math memory mobile module ms msaccess mssqlbackend mysql navigate net opacity pan peertopeervideostreaming picturebox picturebox1 port print printpreview problemwithinstallation project record regex reports" reuse right-to-left save savedialog search serial sorting sqldatbase storedprocedure string temp textbox timer txttoxmlconverter updown useraccounts usercontol usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf xml





