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

Parameter is invalid

0 Answers 98 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kyle
Top achievements
Rank 1
Kyle asked on 03 Aug 2011, 03:25 AM
Hi, I know there are already some people have discussed about this issue. However, I am getting this error intermittently and couldn't manage to reproduce the error. Can anyone point out what's wrong with the code? The ChartReport is created on the fly and inserted to the main report. It throws the 'Parameter is invalid' when trying to set the value of picture box. Thanks in advance.


public partial class ChartReport : Telerik.Reporting.Report
    {
        public ChartReport(ImageReport chart, string chartTitle, string reportName)
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //  
                using (MemoryStream ms = new MemoryStream(chart.Image))
                {
                    ms.Seek(0, SeekOrigin.Begin);
                    Image img = Image.FromStream(ms);
                    Image img2 = CopyImage(img);

                    pcb_Chart.Value = img2; //This line throws the Parameter is invalid error when the value of the picture box control is set
                    txt_ChartTitle.Value = chartTitle;
                }
            this.Name = reportName;
        }

        private Image CopyImage(Image original)
        {
            Image ret = new Bitmap(original.Width, original.Height);
            using (Graphics g = Graphics.FromImage(ret))
            {
                g.DrawImage(original, 0, 0, original.Width, original.Height);
                g.Save();
            }
            return ret;
        }
    }

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Kyle
Top achievements
Rank 1
Share this question
or