i have taken one text field and want coding to print text wrintten in text field on button

Recommended Answers

All 4 Replies

Printer? Want to print text on printer or screen.

Member Avatar for Unhnd_Exception

Drag a printdocument to the form and add this.

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

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

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

End Sub

You have to write your own printing logic. This prints 1 line of text starting at the printers margins.


If this solves your problem mark it as solved, otherwise say why it didn't solve your problem.

commented: Solved :) +11

thanks this works but what i should do when i want to print hole table inside the datagrid view

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.