Data grid is not properly printing RRS feed

  • Question

  • Hi Experts,

    Thanks for your support.

    I am facing a problem while try to print the data grid.

    It is printing only the record am able to see. and not printing the records below the scrolling part.

    I have written the code like this :

    #region PrintDoc
    private void btnPrintDoc_Click(object sender, RoutedEventArgs e)
    PrintDocument doc = new PrintDocument();
    doc.BeginPrint += new EventHandler<BeginPrintEventArgs>(doc_StartPrint);
    doc.PrintPage += new EventHandler<PrintPageEventArgs>(doc_PrintPage);
    doc.Print("Sample Print");
    void doc_PrintPage(object sender, PrintPageEventArgs e)
    e.PageVisual =dataGrid1;
    // Specify whether to call again for another page
    e.HasMorePages = false;
    void doc_StartPrint(object sender, BeginPrintEventArgs e)
    // NOOP

    Can you please suggests me how I will print all rows of my data grid?

    Friday, October 12, 2012 5:53 AM


All replies

  • Please if anyone know this just reply.

    Its my urgent requirement.

    Friday, October 12, 2012 9:24 AM

  • http://www.infragistics.com/community/forums/p/72968/371019.aspx

    Friday, October 12, 2012 10:03 AM
  • Hi Carom,

    Thanks for the link.But this is not sufficient for my requirement.

    Can you tell me how i will solve this?

    Monday, October 15, 2012 1:21 AM
  • Hi Experts I am trying to print the Datagrid in the following approach

    PrintDocument doc = new PrintDocument();
    int itemsIndex = 0;
    doc.PrintPage += (s, pe) =>

    StackPanel itemsHost = new StackPanel();
    while (itemsIndex < loadItem.Count())
    ItemsControl itemsContainer = new ItemsControl();
    itemsContainer.DataContext = loadItem[itemsIndex];
    itemsHost.Measure(new Size(pe.PrintableArea.Width, double.PositiveInfinity));
    if (itemsHost.DesiredSize.Height > pe.PrintableArea.Height && itemsHost.Children.Count > 1)
    pe.HasMorePages = true;
    // return;

    itemsIndex += 1;
    pe.PageVisual = itemsHost;



    Still I am getting error on last line that "Dialogs must be user-initiated."

    Can anybody simplify this?

    Monday, October 15, 2012 4:47 AM
  • Hi, I suggest to create a new DataGrid instance code behind which has the same data source with the DataGrid you want print, and set its width and height bigger enough so that it can fullfill all records without draging scrollbar and then you print the new DataGrid.

    Hope this will help you.

    Best Regards,

    Thursday, October 18, 2012 10:50 AM
  • Hi man.

    It is printing only the record am able to see. and not printing the records below the scrolling part.

    1) Just turn OFF the DataGrid UI Virtualization


    Dialogs must be user-initiated

    1) Create a new DataGrid in the background, fill it with the same data, and print that instead.

    You must read this too:


    Thursday, October 18, 2012 11:45 AM
  • Thank you iTateSLC for your answer,

    I have implemented the way you said,now its working fine.

    But when I try to take a printout ,the page is not properly fit to the datagrid .(As I have more number of columns)

    and how to set if I have more data then it should print in the next page.

    Please suggests me.

    Friday, October 19, 2012 12:17 AM