Dim PrintResult As DialogResult
m_PrintRichTextDocument = New RichTextPrintDocument.RichTextPrintDocument(RichTextBox1)
m_PrintRichTextDocument.DefaultPageSettings = m_PageSettings
With PrintDialog1
.Document = m_PrintRichTextDocument
If RichTextBox1.SelectionLength > 0 Then
.AllowSelection = True
End If
PrintResult = .ShowDialog
If PrintResult = DialogResult.Cancel Then Exit Sub
If .PrinterSettings.PrintRange.Selection = PrintRange.Selection Then
m_PrintRichTextDocument.PrintSelectedTextOnly = True
End If
m_PrintRichTextDocument.Print()
End With