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

Printer? Want to print text on printer or screen.

Member Avatar

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
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