visual basic 2010 priniting

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

JTHEWOLF

Thread Starter
Joined
Dec 26, 2009
Messages
66
hi guys i have a basic word processor. i got all the usual comands e.g.bold,italics,justification etc working. but after i put the print dialogs on and code them to what would make sense i get nothing but blanks pages.

heres my code can someone please help me get this bugger printing :p



Public Class Form1
Dim MyPrintObject As New TextPrint(RichTextBox1.Text)

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.Filter = "Rich Text files (*.rtf)|*.rtf"
OpenFileDialog1.ShowDialog()
RichTextBox1.LoadFile(OpenFileDialog1.FileName)

End Sub

Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
SaveFileDialog1.Filter = "Rich Text files (*.rtf)|*.rtf"
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName)

End Sub

Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Close()
End Sub

Private Sub LeftToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LeftToolStripMenuItem.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Left
End Sub

Private Sub CentreToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CentreToolStripMenuItem.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
End Sub

Private Sub RightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RightToolStripMenuItem.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Right
End Sub

Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click
AboutBox1.Show()
End Sub

Private Sub UnderlineToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UnderlineToolStripMenuItem.Click
Dim currentFont As System.Drawing.Font = RichTextBox1.SelectionFont
If RichTextBox1.SelectionFont.Underline = True Then
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Regular)
Else
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Underline)
End If

End Sub

Private Sub BoldToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BoldToolStripMenuItem.Click
Dim currentFont As System.Drawing.Font = RichTextBox1.SelectionFont
If RichTextBox1.SelectionFont.Bold = True Then
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Regular)
Else
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Bold)
End If

End Sub

Private Sub ItalicToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItalicToolStripMenuItem.Click
Dim currentFont As System.Drawing.Font = RichTextBox1.SelectionFont
If RichTextBox1.SelectionFont.Italic = True Then
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Regular)
Else
RichTextBox1.SelectionFont = New Font(currentFont.FontFamily, currentFont.Size, FontStyle.Italic)
End If

End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub

Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub

Private Sub FontToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem1.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub

Private Sub ColourToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColourToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub

Private Sub PrintToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem1.Click

PrintDialog1.ShowDialog()


End Sub

Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click
RichTextBox1.Clear()

End Sub

Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RedoToolStripMenuItem.Click
RichTextBox1.Redo()
End Sub

Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UndoToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SelectAllToolStripMenuItem.Click
RichTextBox1.SelectAll()
End Sub

Private Sub PrintPreviewDialog1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewDialog1.Load

End Sub

Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
PrintPreviewDialog1.Document = PrintDocument1

PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage

PrintDocument1.Print()

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub
End Class
 

valis

Moderator
Joined
Sep 24, 2004
Messages
78,021
i won't be able to assist that much, but one thing I can do is move it to business apps; you'll get a few more hits there.

thanks,

v
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top