This is a migrated thread and some comments may be shown as answers.

How to print 2 grids one after the other

1 Answer 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe Lozina
Top achievements
Rank 1
Joe Lozina asked on 15 Jul 2010, 07:05 AM
Hi,

I would like to print two grids one after the other with pagination if needed. The best I have got so far is to have one grid on top of another.

Ive tried to set the Canvas.SetTop of the second grid _commentGrid but I havent had any success.

Ive also tried using a StackPanel instead of and within the canvas and it doesn't render anything in the printout.


    private void PrintWeek1_Click(object sender, RoutedEventArgs e)
    {
        _offsetY = 0d;
        _totalHeight = 0d;
 
        CreateLocationPrintGrid();
 
        CreateCommentsPrintGrid();
 
        var doc = new PrintDocument();
 
        _canvas = new Canvas();
 
        _canvas.Children.Add(_locationGrid);
        _canvas.Children.Add(_commentGrid);
 
        doc.PrintPage += DocPrintPage;
        doc.Print("RadGridView print");
    }
 
    void DocPrintPage(object sender, PrintPageEventArgs e)
    {
        e.PageVisual = _canvas;
 
 
        if (_totalHeight == 0)
        {
            _totalHeight = _locationGrid.DesiredSize.Height +_commentGrid.DesiredSize.Height;
        }
 
        Canvas.SetTop(_locationGrid, -_offsetY);

        _offsetY += e.PrintableArea.Height;
        e.HasMorePages = _offsetY <= _totalHeight;
    }
 
}

If you could let me know how to print two grids one after the other I would greatly appreciate it.

Regards,
Joe

1 Answer, 1 is accepted

Sort by
0
Joe Lozina
Top achievements
Rank 1
answered on 15 Jul 2010, 07:44 AM
Its ok, I figured it out.


private void PrintWeek1_Click(object sender, RoutedEventArgs e)
{
    _offsetY = 0d;
    _totalHeight = 0d;
 
    CreateLocationPrintGrid();
 
    CreateCommentsPrintGrid();
 
    var doc = new PrintDocument();
 
    _canvas = new Canvas();
 
    _stackPanel = new StackPanel();
 
    _stackPanel.Children.Add(_locationGrid);
    _stackPanel.Children.Add(_commentGrid);
 
    _canvas.Children.Add(_stackPanel);
 
    doc.PrintPage += DocPrintPage;
    doc.Print("RadGridView print");
}
 
void DocPrintPage(object sender, PrintPageEventArgs e)
{
    e.PageVisual = _canvas;
 
 
    if (_totalHeight == 0)
    {
        _totalHeight = _stackPanel.DesiredSize.Height;
    }
 
    Canvas.SetTop(_stackPanel, -_offsetY);
 
    _offsetY += e.PrintableArea.Height;
    e.HasMorePages = _offsetY <= _totalHeight;
}



Tags
GridView
Asked by
Joe Lozina
Top achievements
Rank 1
Answers by
Joe Lozina
Top achievements
Rank 1
Share this question
or