Hi NazHim-9882,
You can add picturebox image into RDLC Report by following steps:
1.Add pictureBox and two button controls into Form1
2.Add a new form(frmPrint) and then add a Report Viewer to frmPrint form.
You can install Microsoft RDLC Report for Visual Studio via steps below:
Go to Visual Studio’s Tools Menu > Extensions and Update > Select Microsoft RDLC Report Designer and Reporting Services Project for the Visual Studio.
After installing, you have to restart the Visual Studio.
Then you will see that Report and Report Wizard is now available in the Visual Studio.
Right click the project name->Add-> New item->Report
Then design your report as below.
More details you can refer to this document.
3.Add code to handle Form1 form:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string imageUrl = null;
private void button1_Click(object sender, EventArgs e)
{
//Select an image, then display to the picturebox control
using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "JPEG|*.jpg" })
{
if (ofd.ShowDialog() == DialogResult.OK)
{
imageUrl = ofd.FileName;
pictureBox1.Image = Image.FromFile(ofd.FileName);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(imageUrl))
{
//Open print form
using (frmPrint frm = new frmPrint(imageUrl))
{
frm.ShowDialog();
}
}
}
}
4.Add code to handle frmPrint form
public partial class frmPrint : Form
{
string _imageUrl;
public frmPrint(string imageUrl)
{
InitializeComponent();
_imageUrl = imageUrl;
}
private void frmPrint_Load(object sender, EventArgs e)
{
//Read image from file, then set to report parameter
FileInfo fi = new FileInfo(_imageUrl);
ReportParameter pName = new ReportParameter("pName", fi.Name);
ReportParameter pImageUrl = new ReportParameter("pImageUrl", new Uri(_imageUrl).AbsoluteUri);
this.reportViewer1.LocalReport.EnableExternalImages = true;
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pName, pImageUrl });
this.reportViewer1.RefreshReport();
}
}
Test result:
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.