Picturebox with IIF Condition and relative path images

2 posts, 0 answers
  1. Ronald
    Ronald avatar
    1 posts
    Member since:
    Mar 2017

    Posted 08 May 2018 Link to this post

    Hi,

     

    Im trying to display an image using relative path but with IIF condition.

    here is my expression value

    this.pictureBox1.Value = "IIf(Fields.StartTime.Hour > 12, images\\sun-o.png , images\\moon-o-png)";

     

    but this returns an error saying illegal characters in path.. how do i use the IIF condition to display relative path images.

  2. Silviya
    Admin
    Silviya avatar
    414 posts

    Posted 10 May 2018 Link to this post

    Hi Ronald,

    In general, you can assign a string value to the Value property of a PictureBox. This string value can be either an item binding expression or an URI. Check PictureBox Data Binding section of the help article.

    From the provided report definition snippet, I noticed that there is no "=" sign in front of the IIF logical function. By default the report items’ properties are strongly typed. Anyway you can use expressions as value for some of them, like for example PictureBox item. To specify that the value of a property is an expression, the value should be a string starting with equal (=) sign. If the equal sign is not present the value will be interpreted as a string literal.

    Another things to consider are true/false parts of the IIF statement and used relative paths to the images. Based on the logic required for displaying the PictureBox item you described, using the following expression should be sufficient:
    this.pictureBox1.Value = "=IIf(Fields.StartTime.Hour > 12, \"images\\sun-o.png\" , \"images\\moon-o-png\")";

    You also can use a user function that resolves the relative path to an absolute path in PictureBox.Value property.


    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