Print text from inside textbox

i want to be able to print what ever text is in my textbox1. how do l do this

Answer this question

Print text from inside textbox

  • MABeatty

    Look up 'printing' in Help. Specifically, Printing.PrintDocument has a printing example under the constructor method. From there you can link to anything you need to know about printing.

  • sushiko

    can i fill in the X and the Y coordinats

    e.MarginBounds.Top, e.MarginBounds.Left,

    what do i have to change i try'd several things



  • Pickup

    this was answered in thread RE:Print what is in text box

    one additional comment, printdocument will use the default installed printer on the system for printing, the method works like the following:

    for a printing sample refer to:

    ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/dv_vbcodeexpress/html/d511f3be-c329-4ef0-8a9e-42783e611046.htm

    or use the following steps and code to print what is inside the textbox only as you requested :

    first create a printdocument (named printdocument1) from the toolbox and place it on the form.
    second create controls on the form: textbox1 and button1.

    paste the following code:

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

    e.Graphics.DrawString(TextBox1.Text, TextBox1.Font, Brushes.Black, New System.Drawing.RectangleF(e.MarginBounds.Top, e.MarginBounds.Left, e.PageBounds.Width, e.PageBounds.Height))

    '* if you have many pages to print, then create a static counter to check after each page.

    e.HasMorePages = False

    End Sub

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

    PrintDocument1.Print()

    End Sub



  • Print text from inside textbox