Change PictureBox at Runtime

6 posts, 0 answers
  1. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 02 Jul 2012 Link to this post

    Hi there

    I have a trdx file that contains the definition of my report, when I show it with the reportviewer, I would like to change the signature image to the user that is logged in.

    at the moment I have this
    System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
    settings.IgnoreWhitespace = true;
    using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(templatePath, settings))
        Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer = new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
        Telerik.Reporting.Report certificateReport = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
        uxCertificateViewer.ReportSource = certificateReport;

    Im not sure how to access and set the picturebox image before I assign it to the reportViewer. There is no DB data being binded to this report.

    Thank you
  2. Hadib Ahmabi
    Hadib Ahmabi avatar
    181 posts
    Member since:
    Nov 2011

    Posted 03 Jul 2012 Link to this post

    You can try with this method:
    report.Items.Find(Type type, bool recursive);
    and when you find the picture simply change the image data. 
  3. DevCraft banner
  4. Justin
    Justin avatar
    9 posts
    Member since:
    May 2012

    Posted 18 Mar 2013 Link to this post

    I have this same issue with a TRDX report but my report is bound to a datasource. The datasource contains a URL to my picture. How do i set the picture to my file?

    I saw this code in another form-post:
    private void pictureBox1_ItemDataBinding(object sender, EventArgs e)
                Telerik.Reporting.Processing.PictureBox pic = (Telerik.Reporting.Processing.PictureBox)sender;
                string img = HttpContext.Current.Server.MapPath("img.jpg");
                Image myImg = Image.FromFile(img);
                pic.Image = myImg;

    the trdx files don't have code-behind so I don't know where to put it! I also use VB.NET so can you give me a solution in

  5. Jako
    Jako avatar
    107 posts
    Member since:
    Apr 2012

    Posted 19 Mar 2013 Link to this post

    Hi Justin

    What I ended up doing was count the position of the picture box on the actual TRDX in the designer and then do something like this:

    Telerik.Reporting.PictureBox companyLogo = (certificateReport.Items[0].Items[2].Items[1] as Telerik.Reporting.PictureBox);
                if (File.Exists(logoPath))
                    companyLogo .Value = logoPath;

    You should be able to convert this easily to VB.Net
  6. Squall
    Squall avatar
    174 posts
    Member since:
    Feb 2011

    Posted 20 Mar 2013 Link to this post

    Hi Justin,

    Have you tried to set the PictureBox.Value property with expression. Something like this: =Fields.MyPictureURL

  7. Rory
    Rory avatar
    1 posts
    Member since:
    Nov 2015

    Posted 11 Jan Link to this post

    this is how I did it,

     pbLogo.ItemDataBinding += pbLogo_ItemDataBinding;

    void pbLogo_ItemDataBinding(object sender, EventArgs e)
                pbLogo.Value = "=GetLogo(ReportItem)";


    public static Image GetLogo(Telerik.Reporting.Processing.ReportItem reportItem)
                string logo = Utilities.GetLogo(FilePathToImage);
                Image myImg = Image.FromFile(logo);
                return myImg;

Back to Top
DevCraft banner