PictureBox in Product Configurator

Has anyone ever gotten a picture box to work in PC? I’d love to use it for the auto-sizing capability. Unfortunately, it doesn’t recognize .Image and .Value doesn’t work either.

image

The source of an image must come from an image setup under Image Maintenance.

And here it is in a configurator Designer.

Then refere to the images ID that was used in Image Maint.

if(Inputs.ucbCellType.Value != "CU4"){
	Inputs.epiPcPictureBox2.Value = "Logo";
	}
else{
	Inputs.epiPcPictureBox2.Value = "WaltDisney";
	}

Here it is in action:

2 Likes

WOW! Thank you for the detailed information! It doesn’t look like you can URLs though, correct? I can use, and see, these with the browser tool, but the sizing is a nightmare so far.

Yeah, the sizing is an issue. Unlike images in SSRS reports - where you can specif how to handle it (scale, stretch, clip, etc…), the Pict Box in Cfg Entry always stretches the image to fit. :frowning:

If you really wanted to, you could probably query the Image table to get the size of the original image table (Image.Width and Image.Height), and have Cfg Code change the PictBox size.

1 Like

An excellent idea! Thank you so much for your input on this! Cheers!

I tried it out.

I couldn’t query the Image table directly in Configurator Designer event code. But I could make a User Defined Config Method, that could fetch the images dimension.

image

I had problems passing the ImageID to the Method, so I just made a textbox control on the Confg Entry to hold the ImageID. Then referenced that controls value in the UD Method code.

// Enter valid C# code and do not forget this method returns an integer value.
return Db.Image.Where( r =>r.ImageID == Inputs.txtImageID.Value).Select( r =>r.Width).FirstOrDefault();

One odd thing … the Image.Width and Image.Height values are of type decimal.

I had to cast them to int in the Config Editor code that called the UD Method.

here’s code that sets the txtbox value first (so the UD Method can use it)

	Inputs.txtImageID.Value = "WaltDisney";
	int w = (int)UDMethods.ImgWidth();
	Inputs.epiPcPictureBox2.Width = w;
	Inputs.epiPcPictureBox2.Value = "WaltDisney";
1 Like

Correction to the post above. My UD Method specified a return type of decimal. Should have been int.

1 Like