Look at the PrintDocument class in Visual basic. Here is a scaled down, generic example (this is assuming VS2005 and all controls referenced below are added, and does not account for paging or line counting):
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
With PrintDocument1
End With
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
how to print a rich text box
CSharpDavid
Look at the PrintDocument class in Visual basic. Here is a scaled down, generic example (this is assuming VS2005 and all controls referenced below are added, and does not account for paging or line counting):
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then With PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings.Clone
.Print()
End With End If End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPageRichTextBox1.SelectAll()
e.Graphics.DrawString(RichTextBox1.SelectedText, RichTextBox1.SelectionFont, Brushes.Black,
New System.Drawing.RectangleF(e.MarginBounds.Top, e.MarginBounds.Left, e.PageBounds.Width, e.PageBounds.Height))e.HasMorePages =
False End SubStephen G
Thank you, I have been looking for this for some time now..
SrijitCN
Thanks MacMatt_98!