I want to set up a conditional format to hide an image if the byte array count < 2. I cannot figure out how to simply deal with collections such as arrays and get a count.
I've tried this, but my report won't preview in the designer:
= Count(=Fields.[Logo])
How do I achieve this?
Thanks in advance.
Dimitar
Telerik team
commented on 22 Jun 2021, 12:38 PM
The equals sign should only be used at the start of the expression(unless you need to actually check for equality in the expression), there is no need to also have it before Fields.[Logo] so the expression could be changed to the following: =Count(Fields.[Logo]).
With that being said, you could instead try to get the Length property of the array - Fields.[Logo].Length
Thank you that is very helpful. I was trying to check that my length was valid in order to show a picture box in the conditional formatting, but even when my length is < then a number I still see a red box saying 'invalid image data'. Is there a better way to achieve not showing the pic box if there is no image data?
It looks like no matter what the picture box has to be bound to a valid image or you'll get the big red box error, so I just created my own function that returns an empty image if the current one is not valid and use that in the Logo property to ensure a valid image is always returned
Dimitar
Telerik team
commented on 24 Jun 2021, 12:22 PM
Indeed, currently, if the PictureBox has an invalid value, it will error out. Creating a user function that always returns a valid image, is what I would also recommend in this case.
You may be interested in the following feature requests:
The equals sign should only be used at the start of the expression(unless you need to actually check for equality in the expression), there is no need to also have it before Fields.[Logo] so the expression could be changed to the following: =Count(Fields.[Logo]).
With that being said, you could instead try to get the Length property of the array - Fields.[Logo].Length
Indeed, currently, if the PictureBox has an invalid value, it will error out. Creating a user function that always returns a valid image, is what I would also recommend in this case.
You may be interested in the following feature requests:
- Allow disabling picturebox errors via "ShowErrors = false"
- Show a picturebox of which the url is unavailable as a red cross instead of destoying the complete report layout.