|
Hi, when I try to print from my richtextbox it's not printing what I have typed in. I want to be able to print the image that it shows. So if I type in Hello World it will print out Hello World. This goes for color too. Any help would be most appreciated. My code is below.
Thanks
-B
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Runtime.InteropServices
Imports System.Drawing.Printing
Public Class Form1
Dim checkprint As Integer
Private Sub printtext(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
ev.Graphics.DrawString(RichTextBox1.Text, New Font("Arial", 11, FontStyle.Regular), _
Brushes.Black, 120, 120)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim printdoc As New PrintDocument
AddHandler printdoc.PrintPage, AddressOf Me.printtext
printdoc.Print()
End Sub
Private Sub ChangeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeColorToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
RichTextBox1.Focus()
End Sub
Private Sub ChangeFontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeFontToolStripMenuItem.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
RichTextBox1.Focus()
End Sub
End Class
|