![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Not a user?
Join Date: Sep 2007
Posts: 245
Rep Power: 1
![]() |
.Net printing
Does anybody know any good .net printing tutorials? This seems to be a little touched area. Thanks and I will dance at your wedding.
Before you post anything from msdn, I'm already looking at this and trying to understand it. Last edited by Jabo; Dec 1st, 2007 at 1:42 AM. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Re: .Net printing
not sure how much detail you want in your prints. I found this here link on about.com, it shows how to get basic text printing. However that example doesn't provide wrapping, if you print a line that is too long it will be cut off on the right side of the page.
This link seems to be a little more indepth and even shows you how to create a print preview. Hope that helps a little. I am not a VB.NET coder by any means but i do have some understanding of the language.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
|
Re: .Net printing
There's loads of stuff on Visual Basic 6 for printing but not that much in VB.NET. You have to write quite a few lines of code - I'm not sure exactly how to do it. It's easy to print to a file but not so easy to get it out on paper.
Sorry I couldn't be more help, Matt. I |
|
|
|
|
|
#4 |
|
Not a user?
Join Date: Sep 2007
Posts: 245
Rep Power: 1
![]() |
Re: .Net printing
Yeah, VB6 printing was fairly easy, VB.Net is a bit more involved, but what I'm reading sounds to be more standardized and functional.
Right now, I'm just printing (hopefully) a single page. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
Re: .Net printing
if you take a look at those links, they show you how to do it in VB.NET.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#6 |
|
Not a user?
Join Date: Sep 2007
Posts: 245
Rep Power: 1
![]() |
Re: .Net printing
will do...just let me know when you're getting married lol
|
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
Re: .Net printing
If you do manage please could you upload a piece of example code so that people looking back over this thread in the future (i.e. me) might have an idea of how to do it without following external links?
|
|
|
|
|
|
#8 |
|
Newbie
Join Date: Dec 2007
Location: VA
Posts: 1
Rep Power: 0
![]() |
Re: .Net printing
|
|
|
|
|
|
#9 |
|
Omlette du fromage
Join Date: Oct 2007
Posts: 29
Rep Power: 0
![]() |
Re: .Net printing
.NET makes it very easy. I realise this is C# in a VB forum but obviously the principal is the same and VB Syntax just makes my teeth jangle a bit like fingernails on a blackboard, sorry.
using System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Printing;
public partial class MyPrintWindow : Form
{
private int currentPage = 1;
public MyPrintWindow()
{
InitializeComponent();
}
//This can be your menu item click event or whatever you require.
private void btnPrint_Cick(object sender, EventArgs e)
{
try
{
this.currentPage = 1;
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
PrintDialog pDlg = new PrintDialog();
DialogResult dlgResult = pDlg.ShowDialog();
if (dlgResult == DialogResult.OK)
{
pd.Print();
}
}
catch(Exception ex)
{
//do your favourite error handling here
//messagebox, log entry blah...
}
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("Hello", new Font("Arial", 8f), Brushes.Black, new PointF(0f, 0f));
++currentPage;
//Apply your own logic here as to whether more pages are due.
//In my simple example there is only one page.
e.HasMorePages = false;
}
} |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is .net framework | qlb | Visual Basic .NET | 4 | Oct 3rd, 2007 11:52 PM |
| Using .NET 1.1 with Visual Studio 2005 | ReggaetonKing | C# | 2 | Aug 2nd, 2007 12:34 AM |
| Yet another .NET issue | Lesliect6 | Other Programming Languages | 5 | Mar 21st, 2007 8:08 AM |
| VB O5 Program Running Problem..Think its .net framework | Silent | Visual Basic .NET | 3 | Dec 15th, 2005 4:43 AM |
| Goal of .Net Framework or Mono | pr0gm3r | Other Programming Languages | 5 | Sep 9th, 2005 3:28 PM |