Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
Printing a Chart in a Grid
posted

Hi,

 

I have several charts in a grid to support a complex reporting layout.  I can get everything else on the grid to print, but the charts do not show up.  Here is the code to print the grid.  I set the series and some markers in procedural code when the datacontext changes on the form, and this may be the problem, but I can't seem to find any information on printing...

Code:

PrintDialog printDialog = new PrintDialog();if (printDialog.ShowDialog() == true)

{

int pageMargin = 5;

// Get the size of the page.

Size pageSize = new Size(printDialog.PrintableAreaWidth, printDialog.PrintableAreaHeight);

// Trigger the sizing of the element.

gMain.Measure(pageSize);

gMain.Arrange(
new Rect(pageMargin, pageMargin,

pageSize.Width, pageSize.Height));

// Print the element.printDialog.PrintVisual(gMain, "A Scaled Drawing");

// Remove the transform.

gMain.LayoutTransform = null;

}

 In some cases, I get a Null Reference exception and I was able to narrow it down to the charts in the traces....

 

Parents
No Data
Reply
  • 28496
    Offline posted

    i tested this code in the Window_Loaded event handler of a window with a Grid in it, containing a chart.  it showed up OK. 

    could you provide whatever sample code i might need to reproduce this, or maybe some steps for me to follow?

    if you provide the stack trace for a null reference exception, i could also investigate what's going on there. 

Children
No Data