Displaying image in RDLC report viewer.
I want to display an image from my picture box in my RDLC report viewer.
I generate a barcode and display it in the picture box.
private void Print_Click_1(object sender, EventArgs e)
{
Barcode barcode = new Barcode();
int width = (int)(pictureBox_barcode.Width * 0.8);
int height = (int)(pictureBox_barcode.Height * 0.8);
Image img = barcode.Encode(TYPE.CODE39, txtinvoice.Text, Color.Black, Color.Transparent, width, height);
pictureBox_barcode.Image = img;
}
And this is what I do in print_form:
using System.IO;
using BarcodeLib;
public delegate void SetTextTo_PicBarcode(string str_PicBarcode);
namespace PrintReport.PrintReport
{
public partial class frmprint_form: Form
{
public SetTextTo_PicBarcode imageUrl { get; set; }
public frmprint()
{
InitializeComponent();
imageUrl = frmrecipt.Set_imageUrl;
}
}
}
Now, in my report viewer form, I do this:
using System.IO;
using BarcodeLib;
namespace report.report
{
public partial class Frmrecipt : Form
{
string _imageUrl;
public Frmrecipt()
{
InitializeComponent();
}
public void Set_imageUrl(string imageUrl)
{
_imageUrl = imageUrl;
}
private void Frmrecipt_Load(object sender, EventArgs e)
{
reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
if (!string.IsNullOrEmpty(_imageUrl))
{
FileInfo fi = new FileInfo(_imageUrl);
ReportParameter pImageUrl = new ReportParameter("pImageUrl", new Uri(_imageUrl).AbsoluteUri);
this.reportViewer1.LocalReport.EnableExternalImages = true;
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { pImageUrl });
}
this.reportViewer1.RefreshReport();
}
}
}
I created a parameter to display the image.
And this is the problem: if I run my code, this is going to happen.
Developer technologies C#
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more