Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 1st, 2007, 1:28 AM   #1
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
.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.
Jabo is offline   Reply With Quote
Old Dec 1st, 2007, 2:24 PM   #2
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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!
Pizentios is offline   Reply With Quote
Old Dec 1st, 2007, 3:35 PM   #3
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
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
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 1st, 2007, 5:20 PM   #4
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
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.
Jabo is offline   Reply With Quote
Old Dec 1st, 2007, 5:55 PM   #5
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
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!
Pizentios is offline   Reply With Quote
Old Dec 1st, 2007, 6:39 PM   #6
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Re: .Net printing

will do...just let me know when you're getting married lol
Jabo is offline   Reply With Quote
Old Dec 2nd, 2007, 6:03 AM   #7
mattireland
Hobbyist Programmer
 
mattireland's Avatar
 
Join Date: Jul 2007
Location: Wales, United Kingdom
Posts: 190
Rep Power: 2 mattireland is on a distinguished road
Send a message via MSN to mattireland Send a message via Skype™ to mattireland
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?
__________________
Matt Ireland
http://www.mattireland.org
matt@mattireland.co.uk
mattireland is offline   Reply With Quote
Old Dec 4th, 2007, 10:26 AM   #8
cornboy88
Newbie
 
Join Date: Dec 2007
Location: VA
Posts: 1
Rep Power: 0 cornboy88 is on a distinguished road
Re: .Net printing

Try this it may help.

Visual Basic Power Pack

http://www.microsoft.com/downloads/d...displaylang=en
cornboy88 is offline   Reply With Quote
Old Dec 7th, 2007, 5:04 AM   #9
hollystyles
Omlette du fromage
 
hollystyles's Avatar
 
Join Date: Oct 2007
Posts: 29
Rep Power: 0 hollystyles is on a distinguished road
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;
    }
}
hollystyles is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:25 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC