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

Print chart created in winForms

2 Answers 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
luis
Top achievements
Rank 1
luis asked on 12 Aug 2009, 04:52 PM
How can i add a chart previously created in winforms like a print screen for example... with picturebox ?

 

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Aug 2009, 12:58 PM
Hi luis,

You can use the WinForms RadChart control to render the chart into an image stream and then show it in a PictureBox report item. Here is an example:

private void pictureBox1_ItemDataBinding(object sender, EventArgs e) 
        { 
            Telerik.WinControls.UI.RadChart radChart =  
                new Telerik.WinControls.UI.RadChart(); 
            radChart.Width = 600; 
            radChart.Height = 400; 
            Telerik.Charting.ChartSeries chartSeries =  
                new Telerik.Charting.ChartSeries(); 
            chartSeries.Items.Add(new Telerik.Charting.ChartSeriesItem(1)); 
            chartSeries.Items.Add(new Telerik.Charting.ChartSeriesItem(2)); 
            chartSeries.Items.Add(new Telerik.Charting.ChartSeriesItem(3)); 
            chartSeries.Items.Add(new Telerik.Charting.ChartSeriesItem(4)); 
            radChart.Series.Add(chartSeries); 
            MemoryStream ms = new MemoryStream(); 
            radChart.Save(ms, ImageFormat.Png); 
            Telerik.Reporting.Processing.PictureBox pictureBox = 
                (Telerik.Reporting.Processing.PictureBox)sender; 
            pictureBox.Image = Image.FromStream(ms); 
        } 

This code snippet is just to illustrate the approach and you can modify it according to your needs.


Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
BB Agrawal
Top achievements
Rank 1
answered on 12 Sep 2009, 06:42 AM
Hi There,
I have licensed telerik controls (Telerik.Web.UI version 2009.1.527.20). I have parepare StackedBar100 chart using telerik. Now through a button click I want to print/save/export that chart on MS Word / MS ExcelSheet / PDF, but all the other control (label, text box etc) is easlity exportable in the mentioned format but its unable to portray the chart on that. Can you throw some light on that?

Just to let you know that we are working on web application on MS Visual Studio 2008 with dotnet framework 3.5 and language C#.net with asp.net using MS SQL SERVER 2008.
 
Please let me know in case of any issue/concern. I will appreicate if you will reply ASAP.
 
Thanks!
Tags
General Discussions
Asked by
luis
Top achievements
Rank 1
Answers by
Steve
Telerik team
BB Agrawal
Top achievements
Rank 1
Share this question
or