Picturebox use embeeded if bind is null

4 posts, 0 answers
  1. Karl
    Karl avatar
    16 posts
    Member since:
    Nov 2013

    Posted 20 Sep 2018 Link to this post

    I have a picturebox that I am binding to a field on a data item. But if that field is null I want to display a placeholder that is embedded in the report (i.e. as if I had just set the value of the picturebox to an image directly from the explorer). Is this possible? I can't see any way to bind the picture box value to an embedded image as it sets the 'image' property of the picture box in the definition which you can't bind to.
  2. Silviya
    Admin
    Silviya avatar
    354 posts

    Posted 25 Sep 2018 Link to this post

    Hello Karl,

    You can refer to this forum post on the same topic - Picturebox with IIF Condition and relative path images. Basically, you can use IIF statement to check if the field has value then the required picture would be rendered, otherwise a default picture would be rendered. For example:
    this.pictureBox1.Value = "=IIf(IsNull(Fields.DataItemValue, "") = "", \"default.png\", Fields.SubsequentImage)";

    This means that if the field is containing a Null value, will be replaced with default.png , otherwise it will render the value of an subsequent image.

    In case of further issues, open new support ticket and send us the report definition for local testing.

    Regards,
    Silviya
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Karl
    Karl avatar
    16 posts
    Member since:
    Nov 2013

    Posted 25 Sep 2018 in reply to Silviya Link to this post

    Thank you for your response, but this unfortunately doesn't answer my question. Default.png in the case of your example needs to be somewhere on the drive of the machine the report is being generated on. I want the 'else' part of that statement to be the embedded picture that is in the report template itself.
  4. Silviya
    Admin
    Silviya avatar
    354 posts

    Posted 27 Sep 2018 Link to this post

    Hi Karl,

    I'm sorry for misunderstanding you exact requirement for the default *embedded* image.
    In this case this cannot be directly achievable though bindings, because after evaluation of the expression, the Value of the PictureBox will be updated.

    Instead, I can recommend two other approaches:
    1. Set embedded background image to the PictureBox item as default and binding like:
    =IIf(IsNull(Fields.image, "") = "", null, Fields.image)

     in order to achieve the desired behavior.
    2. Use an user function to retrieve the required image with the needed environment setup.

    Regards,
    Silviya
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top