yefchak Posted September 6, 2007 Report Share Posted September 6, 2007 Hi, I was looking at the following code excerpt in another posting on this forum. I'm trying something nearly identical in my code. I seem to create a duplicate chart in memory, but it doesn't seem to print. First, here's the code excerpt I found: private void PrintMosaic (Chart chart) { // Calculate Rows/Cols m_firstPage = true; // Make a coppy of the chart to avoid flickering MemoryStream stream = new MemoryStream(); chart.Export(FileFormat.Binary,stream); stream.Position = 0; m_chart = new Chart(); m_chart.Import(FileFormat.Binary,stream); // Print ... } I'm doing the same thing in VB.net, and the new chart seems OK as far as I can tell. I print using the following approach: m_chart.Paint(g, chartRect, ChartFX.WinForms.PaintStyles.Print) This works fine if I use my original chart, but using the copy produces no output. Is there something else I need to do? Thanks,--George Quote Link to comment Share on other sites More sharing options...
Frank Posted September 6, 2007 Report Share Posted September 6, 2007 I believe the problem is that you are failing to provide the second chart with a size. The size is not serialized into the binary file. Try adding the following right after the call to Import: chart.Width = chartRect.Width; chart.Height = chartRect.Height; chart.UpdateSizeNow(); // Very important. This call commits the changed to the chart layout. Quote Link to comment Share on other sites More sharing options...
yefchak Posted September 10, 2007 Author Report Share Posted September 10, 2007 Thanks. I had tried setting the size, but I didn't call UpdateSizeNow(). That fixed it. :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.