By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,668 Members | 1,716 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,668 IT Pros & Developers. It's quick & easy.

Printcontroller

P: n/a
Hi,

anybody has a snippet for me how to call a printcontroller correctly? My
is not called at all.

find attached a snippet.

Any help is welcome,

Martin
public class PrintUtilsPrintController : PrintController
{
const ulong Delivery = 0x0001;
const ulong Invoice = 0x0002;

PrintUtils m_cPrintUtils;
ArrayList m_alData;
ulong m_ulActType;
int m_nActIndex;

public PrintUtilsPrintController(ArrayList al, PrintUtils pu)
{
m_cPrintUtils = pu;
m_nActIndex = 0;
m_alData = al;

if(al != null && al.Count > 0)
{
switch(al[0].GetType().ToString())
{
case "DODMC.Database.DMCDelNote":
m_ulActType = Delivery;
break;
case "DODMC.Database.DMCInvoice":
m_ulActType = Invoice;
break;
default:
throw new Exception("No valid Type specified!");
}
}
}

public override Graphics OnStartPage(PrintDocument pd,
PrintPageEventArgs e)
{
switch(m_ulActType)
{
case PrintUtilsPrintController.Delivery:
{
DMCDelNote tmp = (DMCDelNote)m_alData[m_nActIndex];
m_cPrintUtils.ActDate = tmp.Date;
m_cPrintUtils.ActIndex = tmp.RecordID;
m_cPrintUtils.Order = tmp.Order;
}
break;
case PrintUtilsPrintController.Invoice:
{
DMCInvoice tmp = (DMCInvoice)m_alData[m_nActIndex];
m_cPrintUtils.ActIndex = tmp.RecordID;
m_cPrintUtils.ActDate = tmp.Date;
m_cPrintUtils.Order = tmp.Order;
}
break;
}

m_nActIndex++;

return base.OnStartPage(pd, e);

//return e.Graphics;
}

public override void OnEndPage(PrintDocument document,
PrintPageEventArgs e)
{
if(m_nActIndex < m_alData.Count)
e.HasMorePages = true;

base.OnEndPage (document, e);
}

public override void OnStartPrint(PrintDocument document,
PrintEventArgs e)
{
base.OnStartPrint (document, e);
}

public override void OnEndPrint(PrintDocument document, PrintEventArgs e)
{
base.OnEndPrint (document, e);
}

}
Nov 16 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.