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

Print out content

14 Answers 360 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Karim
Top achievements
Rank 1
Karim asked on 13 Nov 2012, 02:16 PM

Hello,

I am new to Telerik WinControl. I’m using version 2012.3.1017.40.

I was looking for a control for displaying a chart-diagram in a Windows Forms application. I found the controls “RadChart” and “RadChartView”. Because of the advice of use the control “RadChartView” in your documentation I was making first experiences with this control the last days. As I can see so far, this control seems to be a powerful tool. Having created, configured this control and bound data to it I am looking for the possibility to print out the content of this control. In the documentation I have read that RadChartView does not support the functionality to export its content to a file. I would like to get to know if it is possible to print out the content of a “RadChartView” control anyway.

Karim el Safadi

14 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 16 Nov 2012, 11:54 AM
Hi Karim,

Thank you for writing.

Currently, RadChartView does not support printing as RadGridView and RadScheduler do, but you can still print the control as an image. Please, find attached an example where I paint the control in a Bitmap object and then print this object using a helper class which implements the IPrintable interface. 

I hope this will be useful. Should you have further questions, I would be glad to help.
 
All the best,
Ivan Petrov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Xavier Soares
Top achievements
Rank 2
answered on 03 Dec 2012, 04:45 PM
Hello Ivan,

I've used Your code but, the data that is presented in  the RadPrintDocument isn't sent to the printer. It loads/shows the graph correctly but It does not send it to the printer.

What's missing me?

Thank you.
Best regards,
Luís Maurício
0
Ivan Petrov
Telerik team
answered on 06 Dec 2012, 09:09 AM
Hi Luís,

Thank you for writing.

There are several things to check out in this situation - your printer connection, drivers, supplies (ink, paper). Try printing a document from another application (e.g. Office Word). Try printing a RadGridView/RadScheduler. In the print dialog check whether you have selected the right printer. If you are trying to print to a file check whether PrintToFile is allowed. 

I hope this will help. Feel free to write back with any further questions.
 
Greetings,
Ivan Petrov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 30 Jan 2013, 08:32 PM
Hi Ivan,
returning null in GetSettingsDialog() seems to crash the Application (2012Q3SP1 newest Hotfix)
Regards
Erwin
0
Hewitt
Top achievements
Rank 2
answered on 31 Jan 2013, 08:48 AM
Works great if the Chart is small, but make it fill the screen and try it. The chart does not fit to the page.

Ideally, I would set the page to landscape and have some AutoFit to the page bounds.

Could you advise?
0
Ivan Petrov
Telerik team
answered on 01 Feb 2013, 03:12 PM
Hi Matthew and Erwin,

Thank you both for writing.

@Erwin
Returning null would crash the app if you click on the settings button of the print preview dialog. You should either disable/hide this button or you can provide a custom settings dialog which should inherit Form/RadForm.

@Matthew
I have attached a modified version of the project from my first post which scales the chart image to fit in the page bounds.

If you have further questions, I would be glad to help.

Kind regards,
Ivan Petrov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 01 Feb 2013, 04:37 PM
Thanks Ivan,

for those following this thread:

To print out in Landscape mode, set the RadPrintDocument.Landscape Property to true.
I've also added a quick hack to try and disable the settings ToolBar Button.
Additionally I've extended the ChartPrinter Class to take and print a page title.
private void printButton_Click(object sender, EventArgs e)
      {
          RadPrintDocument document = new RadPrintDocument();
          document.Landscape = true;
          document.AssociatedObject = new ChartPrinter(this.usageChartView,this.Machine.PrintableName + " - Software Usage");
          RadPrintPreviewDialog dialog = new RadPrintPreviewDialog(document);
 
          try
          {
              // try to disable the print settings button
              dialog.ToolCommandBar.CommandBarElement.Rows[0].Strips[0].Items[1].Enabled = false;
          }
          catch (Exception)
          {
              ;
          }
 
          dialog.ShowDialog();
      }

Regards
Erwin

 

0
Hewitt
Top achievements
Rank 2
answered on 04 Feb 2013, 02:53 PM
Thanks all for your help.
The Chart is now scaling to the page nicely, however referring to the original post, when trying to print to the printer, there is an issue.
1. Load the Chart onto the document.
2. Click the [Print] command bar button.
3. Select the required printer.
4. Click [Print]

A dialog saying "Printing 1 of Document" appears, but no printing happens. 

I have tested the printer by printing to it from other applications and it is working fine.
0
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 04 Feb 2013, 07:14 PM

I guess the ChartPrinter IPrintable Implementation EndPrint() function should return true instead of false
According to the docs, EndPrint() returns false if the printing was cancelled.


public bool EndPrint(RadPrintDocument sender, PrinterEventArgs args)
{
    // return false;  -- suspected problem here
    return true;
}


Regards
Erwin
0
Ivan Petrov
Telerik team
answered on 06 Feb 2013, 02:09 PM
Hello guys,

Thank you for writing.

Indeed, the EndPrint method should return true. Thank you Erwin for that point.

@Matthew: If you are still experiencing issues, please write back with more information on the situation.
 

Regards,
Ivan Petrov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Hewitt
Top achievements
Rank 2
answered on 06 Feb 2013, 02:13 PM
Now I feel like a fool
Yes. Changed the return to True and it works a treat.

Thank you all!
0
Ivan Petrov
Telerik team
answered on 08 Feb 2013, 10:50 AM
Hi fellas,

@Matthew: I am glad we were able to resolve the issue and came out with a working solution that satisfies your needs.

@Erwin: Thank you for your cooperation. Your Telerik points have been updated.

If there are further questions that need clarification, do not hesitate to write again.

Greetings,
Ivan Petrov
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
Todd
Top achievements
Rank 1
answered on 12 Nov 2014, 08:57 PM
Related to Erwin's  01 Feb 2013 post...

I am having the same trouble with the print settings button on the RadPrintPreviewDialog, a complete app crash:

Object not set to an instance of an object...
  at Telerik.WinControls.UI.RadPrintPreviewDialog.OnShowPrintSettingsDialog()\r\n   at Telerik.WinControls.UI.RadPrintPreviewDialog.buttonSettings_Click(Object sender, EventArgs e)\r\n   at Telerik.WinControls.RadElement.OnMouseDown(MouseEventArgs e)\r\n   at Telerik.WinControls.RadItem.OnMouseDown(MouseEventArgs e)\r\n   at Telerik.WinControls.RadElement.OnCLREventsRise(RoutedEventArgs args)\r\n   at Telerik.WinControls.RadElement.OnBubbleEvent(RadElement sender, RoutedEventArgs args)\r\n   at 
...
...
...

Erwin's code to disable the settings button worked, but I would like to know if there are any known reasons (and fixes) for the underlying cause?

We're using the 2014.2.715.20 versions, Windows 7 in a VS2013 IDE.






0
Dimitar
Telerik team
answered on 17 Nov 2014, 11:33 AM
Hello Todd,

Thank you for writing.

RadChartView now supports this functionality out of the box and you do not need to use this sample project any more. Detailed information is available here: Printing.

Please let me know if there is something else I can help you with. 

Regards,
Dimitar
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ChartView
Asked by
Karim
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Xavier Soares
Top achievements
Rank 2
erwin
Top achievements
Rank 1
Veteran
Iron
Hewitt
Top achievements
Rank 2
Todd
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or