How do i get the printpreview to recognize my txtDocument.Text  
Author Message
robertlamour





PostPosted: Visual Basic Express Edition, How do i get the printpreview to recognize my txtDocument.Text Top


Re: How do I get the print preview dialog to show me the txtDocument.Text
Was this post helpful

Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrintPreview.Click

ppdPreview.Document = txtDocument.Text

ppdPreview.ShowDialog()

End Sub

do you see where it says txtDocument.Text This is a textBox that implements the text to be previewed as the dialog. But my source code does not recognize this document. I need a new statement to recognize this txtDocument.Text to be previewed....



Visual Studio Express Editions38  
 
 
Tall Dude





PostPosted: Visual Basic Express Edition, How do i get the printpreview to recognize my txtDocument.Text Top

 

To quote part of my second post, when you posted this question earlier:

quote: (added now, words in red)

' A 'PrintDocument' is not something to be printed.

' It is a collection of settings, margins, portrait

' landscape, resolutions, default printer etc.

' What needs to be printed, OR PRINT PREVIEWED is introduced in the PrintDocument's

' PrintPage event handler subroutine (method).

unquote.

In my large example response to your earlier post;

find the section shown below and change 'textbox1.text'

to read 'txtDocument.Text'

Private Sub textbox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles textbox1.TextChanged

StringToPrint = textbox1.Text

End Sub

 



 
 
Gary Lam





PostPosted: Visual Basic Express Edition, How do i get the printpreview to recognize my txtDocument.Text Top

It seems to me like txtDocument.Text is a multi line text box that contain your document text.

for sure I can't see where it said
txtDocument.Text from this small function.

if txtDocument is a text box
.Text will generate a String.
if ppdPreview is a custom build method, you need to look into the Document Type

see if there is something Document.Write(String s).

Public <funkyType> Document
Get
return mdoc
Set
mdoc= value

you need to look into the type and see if it is a value type or need to pass in some a string throught Methods
forexmple Document.Write(string s).

Hope this help.
If not you need to post
1) how do you declare ppdPreview
2) what is the type Document is it a string a char a int or custom type

Then we can help you further

Cheers,
Gary.


 
 
Tall Dude





PostPosted: Visual Basic Express Edition, How do i get the printpreview to recognize my txtDocument.Text Top

The shortest example I can come up with that does nothing fancy.

Public Class Form1

' Using 1 textbox standard name (textbox1), 1 printpreviewdialog

' standard name PrintPreviewDialog1, and 1 button, standard name

' (button1) and 1 printdocument, standard name (Printdocument1)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

PrintPreviewDialog1.Document = PrintDocument1

PrintPreviewDialog1.ShowDialog()

' The next line would print the textbox

' PrintDocument1.print()

End Sub

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

' This sub is used both to print and to print preview.

' The system just changes the controller from either

' print or printpreview

e.Graphics.DrawString(TextBox1.Text, Me.Font, Brushes.Black, 0, 0)

End Sub

End Class