-
help printing
I know I have had several New Threads here lately that is because I think no one understands what I am trying to do. I am trying to get the printout on a peice of paper to look like this:
1. example
KF
123
O45
1975
and not like this:
2. example
KF 123 O45 1975
In one of the threads someone had sent me some code which I have listed below when I try it, it comes out looking like example 2.:
Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Replica_of_db181DataSet.CARD_CATALOG' table. You can move, or remove it, as needed.
Me.CARD_CATALOGTableAdapter.Fill(Me.Replica_of_db181DataSet.CARD_CATALOG)
End Sub
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 System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim fnt As New Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point)
e.Graphics.DrawString(TextBox1.Text, fnt, Brushes.Black, 0, 0)
TextBox1.Multiline = True
e.HasMorePages = False
End Sub
End Class
I want the code to print out the data to look like example 1. I hope there is someone out there that can help me
-
help printing
Could you tell me if there is some other forum on the internet that would work better for me to get my problem looked at and answered by someone.
-
This May Help
I am no expert in printing, which can be pretty clumsy in Visual Studio, but I'll make a suggestion. Instead of hoping your very narrow multi-line text box will be rendered accurately by the print routine, why don't you force the issue by inserting carriage returns and line feeds between each of the parts.
Try the following:
Code:
'In your current Button1_Click,
'assign the content of TextBox1.Text to OneLineText
Dim OneLineText As String = TextBox1.Text
Dim Parts() As String
Dim TextWith_CR_and_LFs As String = ""
'add Cr&Lf to each part
Parts = OneLineText.Split(" ")
For Each Part In Parts
TextWith_CR_and_LFs &= Part & vbCrLf
Next
'assign the split-up text back to TextBox1.Text
TextBox1.Text = TextWith_CR_and_LFs
'Then call PrintDocument1.Print()
Good luck!
Benn Gibson
-
help printing
Thank you for the post but I did not think anyone would post and so I have not checked back until today. I did try the code you gave to me but it did not work it printed a blank page. and on the screen inside of the textbox it shows the return charecters what could be wrong.
-
What do you mean "on the screen inside of the textbox it shows the return charecters"? I don't know what "return characters" are.
Are you trying to say that the screen shows accurately what you hope it would, but nothing gets printed?
Benn Gibson
Similar Threads
-
By Newton in forum VB Classic
Replies: 2
Last Post: 11-11-2008, 10:46 AM
-
By vb_programmer in forum VB Classic
Replies: 0
Last Post: 10-20-2006, 03:35 PM
-
By Newton in forum VB Classic
Replies: 0
Last Post: 01-25-2002, 05:59 AM
-
By dandy in forum ASP.NET
Replies: 0
Last Post: 08-27-2001, 04:00 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|