C# Richtextbox Print

Posted on 2011-10-18
Last Modified: 2012-05-12
Hi. I have to do a change in some old C# code.. it´s a big program so I can´t just redo the whole program.

Today they have LPT-port printers...  Step 1 is to change this to thernet new printers..
But my first task is this.

The program collect some data into a Richtextbox. Then it writes this out to a printer..
.I can´t understand that it should be this hard to do a print from a Richtext box..
I have google for a big time now but can´t figure this out..

Can someone give me som tips...
Can I do something like this

richtextbox.print() ore something...
Question by:kavvis
    LVL 22

    Accepted Solution

    Look here


    Ivo Stoykov

    Author Comment

    thank you for your replay...

    I´m pretty new att C# so I got some problems to include this...

    On a button click I do this..

     PrinterSettings settings = new PrinterSettings();
         prtxt = RptText.Text;

    //and then I try to include this part..

            // Print RichTextBox content
            private void PrintCommand()
                PrintDialog pd = new PrintDialog();
                if ((pd.ShowDialog() == true))
                    //use either one of the below      
                    pd.PrintVisual(richTB as Visual, "printing as visual");
                    pd.PrintDocument((((IDocumentPaginatorSource)richTB.Document).DocumentPaginator), "printing as paginator");

    But I cant figure this out :(
    LVL 22

    Assisted Solution

    by:Ivo Stoykov
    what's the problem?

    Author Comment

    I will get back to you with new info asoon as I can...

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now