Hello to all,
How to print the contents of textboxes in proper formate like
Student Name ABC
Father Name BDC
DOB 14/02/2011
Please help if any body know
Thanks in advance.
Hello to all,
How to print the contents of textboxes in proper formate like
Student Name ABC
Father Name BDC
DOB 14/02/2011
Please help if any body know
Thanks in advance.
Hi,
Here's a way how to print the contents of a Label and TextBoxes.
For example add two labels to a panel and name them Students Name and Fathers Name.
Next to the Labels add two Textboxes where you can write the contents.
Then add two buttons and a PrintPreviewDialog and a PrintDialog.
Try this:
Imports System.Drawing.Printing
Public Class Form1
Private WithEvents pndocument As PrintDocument
Private Sub btnshowpreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnshowpreview.Click
Dim previewmode As New PrintPreviewDialog
pndocument = New Printing.PrintDocument
previewmode.Document = pndocument
previewmode.ShowDialog()
pndocument = Nothing
End Sub
Private Sub btnprint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprint.Click
pndocument = New PrintDocument
pndocument.Print()
End Sub
Private Sub pndocument_Printpage(ByVal sender As Object, ByVal e As Printing.PrintPageEventArgs) Handles pndocument.PrintPage
Dim prFont As New Font("Calibri", 24, GraphicsUnit.Point)
e.Graphics.DrawString( _
Label1.Text, prFont, _
Brushes.Black, 30, 30)
e.Graphics.DrawString( _
Label2.Text, prFont, _
Brushes.Black, 30, 70)
e.Graphics.DrawString(TextBox1.Text, prFont, Brushes.Black, 300, 30)
e.Graphics.DrawString(TextBox2.Text, prFont, Brushes.Black, 300, 70)
End Sub
End Class
To print the proper format in the textboxes you need to ask the user to use the proper format.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.