Click here to Skip to main content
16,005,138 members
Home / Discussions / C#
   

C#

 
GeneralRe: Make a program run at startup? Pin
methhoo25-Jan-08 7:55
methhoo25-Jan-08 7:55 
GeneralRe: Make a program run at startup? Pin
Jimmanuel25-Jan-08 7:59
Jimmanuel25-Jan-08 7:59 
GeneralRe: Make a program run at startup? Pin
J a a n s24-Jan-08 20:59
professionalJ a a n s24-Jan-08 20:59 
QuestionRe: Make a program run at startup? Pin
methhoo25-Jan-08 4:58
methhoo25-Jan-08 4:58 
Generalselecting table adapters in datasets Pin
Glen Harvy24-Jan-08 11:15
Glen Harvy24-Jan-08 11:15 
GeneralRe: selecting table adapters in datasets Pin
Gareth H24-Jan-08 11:37
Gareth H24-Jan-08 11:37 
GeneralRe: selecting table adapters in datasets Pin
Glen Harvy24-Jan-08 13:23
Glen Harvy24-Jan-08 13:23 
QuestionPrint multiple copies of a page? Pin
DaleEMoore24-Jan-08 10:49
DaleEMoore24-Jan-08 10:49 
Hi All:

I've been trying to figure out how to print multiple copies of a page. This code is as close as I've been able to come, but I get odd results. The first time I try to print I specify 2 pages and I get 4 pages. Without leaving the program, the second time I try to print I specify 2 pages and I get one page printed with the second page on top of the first.

Any thoughts you have are very much appreciated!
Dale E. Moore

using System;<br />
using System.Drawing;<br />
using System.Drawing.Printing;<br />
using System.Windows.Forms;<br />
namespace MultipleCopies<br />
{<br />
    public partial class Form2 : Form<br />
    {<br />
        private PrintDocument printDoc = new PrintDocument();<br />
        private int copiesToPrint;<br />
        public Form2()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
        private void button1_Click(object sender, EventArgs e)<br />
        {<br />
			printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); <br />
			PrintDialog dlg = new PrintDialog();<br />
			dlg.PrinterSettings = new PrinterSettings();<br />
			if (dlg.ShowDialog() == DialogResult.OK) {<br />
                copiesToPrint = dlg.PrinterSettings.Copies;<br />
				printDoc.Print();			<br />
			}<br />
        }<br />
        private void printDoc_PrintPage(Object sender, PrintPageEventArgs e) {<br />
			String textToPrint = "Printing " + copiesToPrint;<br />
			Font printFont = new Font("Courier New", 12);<br />
			int leftMargin = e.MarginBounds.Left;<br />
			int topMargin = e.MarginBounds.Top;<br />
			e.Graphics.DrawString(textToPrint, printFont, Brushes.Black, leftMargin, topMargin);<br />
            copiesToPrint--;<br />
            if (copiesToPrint < 1) <br />
                e.HasMorePages = false;<br />
            else <br />
                e.HasMorePages = true;<br />
		}<br />
        [STAThread]<br />
        static void Main()<br />
        {<br />
            Application.Run(new Form2());<br />
        }<br />
    }<br />
}

GeneralRe: Print multiple copies of a page? Pin
Gareth H24-Jan-08 10:59
Gareth H24-Jan-08 10:59 
GeneralRe: Print multiple copies of a page? Pin
DaleEMoore24-Jan-08 11:22
DaleEMoore24-Jan-08 11:22 
GeneralRe: Print multiple copies of a page? Pin
DaleEMoore24-Jan-08 11:30
DaleEMoore24-Jan-08 11:30 
QuestionIssue using .dll in Program vs Service Pin
abupsman24-Jan-08 9:43
abupsman24-Jan-08 9:43 
GeneralRe: Issue using .dll in Program vs Service Pin
Luc Pattyn24-Jan-08 10:15
sitebuilderLuc Pattyn24-Jan-08 10:15 
GeneralRe: Issue using .dll in Program vs Service Pin
abupsman24-Jan-08 10:30
abupsman24-Jan-08 10:30 
GeneralRe: Issue using .dll in Program vs Service Pin
Luc Pattyn24-Jan-08 10:51
sitebuilderLuc Pattyn24-Jan-08 10:51 
GeneralRe: Issue using .dll in Program vs Service Pin
abupsman24-Jan-08 11:56
abupsman24-Jan-08 11:56 
GeneralRe: Issue using .dll in Program vs Service Pin
Luc Pattyn24-Jan-08 12:04
sitebuilderLuc Pattyn24-Jan-08 12:04 
GeneralCustom tab control Pin
DanB198324-Jan-08 7:58
DanB198324-Jan-08 7:58 
GeneralRe: Custom tab control Pin
led mike24-Jan-08 9:41
led mike24-Jan-08 9:41 
GeneralRe: Custom tab control Pin
DanB198324-Jan-08 9:50
DanB198324-Jan-08 9:50 
GeneralRe: Custom tab control Pin
led mike24-Jan-08 10:31
led mike24-Jan-08 10:31 
GeneralRe: Custom tab control Pin
DanB198325-Jan-08 0:14
DanB198325-Jan-08 0:14 
GeneralRe: Custom tab control Pin
led mike25-Jan-08 5:56
led mike25-Jan-08 5:56 
GeneralRe: Custom tab control Pin
DanB198326-Jan-08 1:29
DanB198326-Jan-08 1:29 
QuestionWPF Transparent Window - can it still detect events? Pin
Member 429406224-Jan-08 7:44
Member 429406224-Jan-08 7:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.