473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Printing the contents of a textbox

In VB i had some very very simple code that would print out the contents of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???
Apr 4 '06 #1
7 6018
"Jonathan Smith" <Jo***********@discussions.microsoft.com> schrieb:
In VB i had some very very simple code that would print out the contents
of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???


That's not as easy. You will have to use the 'PrintDocument' object and
draw the string onto the printer using 'e.Graphics.ToString' in the
'PrintDocument''s 'PrintPage' event handler. 'PrintDocument' won't to
paging automatically, so you'll have to measure the text you are printing
and start a new page using 'e.HasMorePages' manually, which will cause
'PrintPage' to be called one more time for the next page.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 4 '06 #2
Are you serious????

All i want to do is print the contents of a textbox

"Herfried K. Wagner [MVP]" wrote:
"Jonathan Smith" <Jo***********@discussions.microsoft.com> schrieb:
In VB i had some very very simple code that would print out the contents
of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???


That's not as easy. You will have to use the 'PrintDocument' object and
draw the string onto the printer using 'e.Graphics.ToString' in the
'PrintDocument''s 'PrintPage' event handler. 'PrintDocument' won't to
paging automatically, so you'll have to measure the text you are printing
and start a new page using 'e.HasMorePages' manually, which will cause
'PrintPage' to be called one more time for the next page.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Apr 4 '06 #3
"Jonathan Smith" <Jo***********@discussions.microsoft.com> schrieb:
Are you serious????


Yes, I am.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Apr 4 '06 #4
Jonathan,

The .Net framework includes classes that allow you to build sophisticated
print capabilities into an app.

But something as simple as the VB6 Printer object is not included.

You can google for .Net printing and find several third-party tools that
attempt to give you capabilities similar to the VB6 Printer object. I have
not tried these tools so I can't recommend any of them.

Kerry Moorman
"Jonathan Smith" wrote:
In VB i had some very very simple code that would print out the contents of a
textbox for me.

It was simply

Sub PrintTB()
Printer.Print(Text1.Text)
End sub

Very simple, and 110% effective.

How the hell do i do this in VB .Net???

Apr 4 '06 #5
perhaps this is what you mean?

Debug.Writeline("Hello")

Apr 4 '06 #6
That won't print to the printer like he wishes to do.
james

"Aziz" <az*****@googlemail.com> wrote in message
news:11********************@u72g2000cwu.googlegrou ps.com...
perhaps this is what you mean?

Debug.Writeline("Hello")

Apr 4 '06 #7

"Jonathan Smith" <Jo***********@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
Are you serious????

All i want to do is print the contents of a textbox


There's a really good run down of how do this in "Visual Basic 2005 Express
Edition for Dummies 2005", CHAPTER 9

Hint:
http://www.dummies.com/WileyCDA/Dumm...51,page-1.html
Apr 10 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the...
3
by: Bryan Z | last post by:
I was wondering how do you print just part of a webform in asp.net -- like just printing the contents of a textbox or label. I know that it will involve javascript, but I cannot get the javascript...
2
by: freddy | last post by:
I am new to c#, I am trying to print the context of a textbox or a combobox.
4
by: Grahammer | last post by:
This is a stupid question, but the examples I've seen don't make sense to me... I simply want to print the contents of a textbox to a printer when the user clicks a button on my form. Printing...
5
by: Tom | last post by:
I am converting an old application that was printing directly to a specialized printer device (i.e. a special label printer). It was doing this by opening a file with the file path of 'LPT1:' and...
6
by: randy1200 | last post by:
I'm using Visual Studio 2005 and C#. I need to print a WinForm used for data entry as a graphic. In other words, I need to print the exact WinForm the user sees on the screen. I searched through...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.