Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Printouts in WPF VB

$
0
0

I have looked on the forums and have found KB articles such as  http://msdn.microsoft.com/en-us/library/aa970848(v=vs.110).aspx however this particular one doesn't work for me (XPS doc type not defined, so Iimport :Imports System.Windows.Xps.Packaging then get the error File access not defined: so i change that to IO.FileAccess.Read, then when it finally works (after putting a file in to C:\FixzedDocumentSequence.xps) i get the further problems of it printing that problem.)

, I need to print a multi lined text box, i have some code that does work: 

 Private Sub Print_Click()
        Dim text As String = Textbox.Text
        Dim printCaption As String = "Item"

        Dim doc As New FlowDocument(New Paragraph(New Run(text)))
        doc.PagePadding = New Thickness(100) 'Creates margin around the page
        Dim diag As New PrintDialog() 
        diag.PrintDocument( _
            CType(doc, IDocumentPaginatorSource).DocumentPaginator, printCaption)
    End Sub

however this only prints to the default printer, i would like to get the Printer Dialogue up to choose which printer to use. It could create the XPS file to use based on the Text box? (i will also be making a save feature to save data to a document ready for emailing)  if I would also like it to add an image or table to the document would this be possible?

to summarize:

1.how do I print a text box to a printer of my choice?

2.how do I print a data grid to a printer of my choice?

3.can I print both a text box and data grid to a single page?

Thanks, 


Michael Booth


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>