Go4Expert

Go4Expert (http://www.go4expert.com/)
-   ASP (http://www.go4expert.com/forums/asp/)
-   -   Trouble Printing Multi-Page DataGrid (http://www.go4expert.com/forums/trouble-printing-multi-page-datagrid-t24077/)

sandygrdn 3Dec2010 14:51

Trouble Printing Multi-Page DataGrid
 
I am having trouble printint a DataGrid across multiple pages. Here is the code I am using in the main page:

Code:

Code:

PrintDocument doc = new PrintDocument();
            BackupPage page = new BackupPage();
                List<object>allItems = myGrid.ItemsSource.OfType<object>().ToList();
            doc.Print("Backup Report");
            doc.PrintPage += (s, ea) =>
                {
                    int numberOfLinesAdded = 0;
                    while (lineIndex < allItems.Count)
                    {
                        page.SetHeaderAndFooterText(account.Text, start.Text, end.Text);
                        page.add_line(allItems[lineIndex]);
                        page.Measure(new Size(ea.PrintableArea.Width, double.PositiveInfinity));
                        if (page.DesiredSize.Height > ea.PrintableArea.Height && numberOfLinesAdded > 0)
                        {
                            page.remove_line(allItems[lineIndex]);
                            ea.HasMorePages = true;
                            break;
                        }
                        lineIndex++;
                        numberOfLinesAdded++;
                    }
 
                    ea.PageVisual = page;
                };

And on BackupPage:

Code:
Code:

public partial class BackupPage : UserControl
    {
        List<object> report = new List<object>();
 
        public BackupPage()
        {
            InitializeComponent();
            InvoiceDate.Text = DateTime.Today.ToShortDateString();
            myGrid2.ItemsSource = report;
        }
 
        public void SetHeaderAndFooterText(string account_name, string start_date, string end_date)
        {
            account.Text = account_name;
            end.Text = end_date;
            start.Text = start_date;
        }
 
        public void remove_line(object item)
        {
            report.Remove(item);
        }
 
        internal void add_line(object item)
        {
            report.Add(item);
        }
    }

I am taking the rows from the main page "myGrid" and sending them to a BackupPage "myGrid2", but the rows don't show up. I have the myGrid2 set up exactly like myGrid. In the debugger I can see the count on report on BackupPage increment as well as the ItemsSource on myGrid2. So the rows are inserting into the page and the grid, they just aren't displaying on the printed page for some reason.

I can't think of any reason that this isn't working. Any help would be greatly appreciated.

amtindia 3Dec2010 15:31

Re: Trouble Printing Multi-Page DataGrid
 
Check out this video on Multiple Page Printing

Hope it does helps.

Advanced Millennium Technologies, a leading global services company, provides consulting, implementation, business transformation and operational solutions for clients across the globe. Feel free to hire a dedicated & skilled team of experts for developing your Custom Applications on Microsoft Silverlight platform.

Warm Regards,
Aby Varghese
Director At AMT

amtindia 3Dec2010 15:37

Re: Trouble Printing Multi-Page DataGrid
 
channel9.msdn.com/learn/courses/Silverlight4/SL4BusinessModule6/SL4LOB_06_02_MultipagePrinting


All times are GMT +5.5. The time now is 08:13.