This is a migrated thread and some comments may be shown as answers.

Picturebox with IIF Condition and relative path images

1 Answer 598 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ronald
Top achievements
Rank 1
Ronald asked on 08 May 2018, 06:36 AM

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.

1 Answer, 1 is accepted

Sort by
0
Silviya
Telerik team
answered on 10 May 2018, 08:06 AM
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
Tags
General Discussions
Asked by
Ronald
Top achievements
Rank 1
Answers by
Silviya
Telerik team
Share this question
or