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:



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.Measure(new Size(ea.PrintableArea.Width, double.PositiveInfinity));
                        if (page.DesiredSize.Height > ea.PrintableArea.Height && numberOfLinesAdded > 0)
                            ea.HasMorePages = true;
                    ea.PageVisual = page;

And on BackupPage:


public partial class BackupPage : UserControl
        List<object> report = new List<object>();
        public BackupPage()
            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)
        internal void add_line(object 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

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