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

Print Selected Records on canvas

P: 1
I want to print Selected Records on canvas (For Demand Draft Printing) using silverlight 4 C#.

1: on my mainpage.xmal I taken Data grid with Check box selection and Canvas.

2: I want to print Selected record on Canvas but it is not printing it give a exception error,

i.e Dialogs must be user-initiated.(Security Exception was unhanded by user) following code i do but it not working properly pl help me to do this.

private void btnPrint_Click(object sender, RoutedEventArgs e)
{
int count = 0;
int printCount = 0;
PrintDocument docToPrint = new PrintDocument();

foreach (ServiceReference1.DDDEMO dd in obcDDDemo)
{
textBlock1.Text =dd.Name.ToString(); //Payee name.
textBlock2.Text =dd.Amount.ToString();//Amount

docToPrint.PrintPage += (s, args) =>
{
args.PageVisual = canvas1;
printCount++;

if (printCount < count)
{
args.HasMorePages = true;
}
else
{
args.HasMorePages = false;
}
};
docToPrint.Print("Document");
}
}
Nov 2 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.