Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Problem

How to get image from memory stream and pass it to rdlc ?

I work in windows form application c# project VS2015 contain two windows form

form 1

form 2

in form 1 i generate qr code image in picture box and save it in memory stream

Under generate button click
C#
MemoryStream memorystream = new MemoryStream();  
 
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();  
                           encoder.QRCodeScale = 8;  
                           
  
                         
                           string encoding = "UserName : " + textBox4.Text + "\r\n" + "Country : " + comboBox3.Text + "\r\n" + "Membership :" + comboBox5.Text;  
                           
                            
                           Bitmap bmp = encoder.Encode(encoding);  
                           pictureBox1.Image = bmp;  
                           bmp.Save(memorystream, ImageFormat.Jpeg);


Until Now i dont have any problem

I generate qr code and recieve it in picture box1 correctly and save it in memory stream
My problem how to pass memory stream from form1 to RDLC ?

in form2
Report viewer found in form 2 this is place of display RDLC
IN button get report in form 1
How to represent memory stream here
if (pictureBox1.Image != null)
{
var f = new Form2(How to represent memory stream here);

f.Owner = this;
try
{
f.ShowDialog();
}
finally
{
f.Dispose();
}

}

but how to pass memory stream to rdlc that will show in form 2

In form load event of form 2

How to getmemorystream to image path

C#
string imagePath = How to getmemorystream to image path;  
            reportViewer1.LocalReport.EnableExternalImages = true;  
           
            ReportParameter rpt4 = new ReportParameter("parmimage", imagePath);  
           
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpt4 });  
            
            this.reportViewer1.RefreshReport();


What I have tried:

How to get image from memory stream in form1 and pass to rdlc report in form2
Posted
Updated 30-Jan-17 2:16am

1 solution

There are a series of tips here on CodeProject that will help you on the topic of passing information between forms. The first one is here Transferring information between two forms, Part 1: Parent to Child[^] and there are links to the others within that article
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900