in the tools is an epipicturebox. Thatās what the screen that you show is using. Can you just use that and bind it with the properties that the stock ones use? (I havenāt done it before, but thatās where I think I would start.)
I use The EpiPictureBox object. to show images from our location on the server. In order to show the part picture if exists:
string file = BuildImagePath(); //from the image location path we deduct from the customerID /partnumber/revnumber etc...
if (File.Exists(file))
{
ImagePieceRev.Image = Image.FromFile(file);
}
The images were saved the same size pixels as the picturebox size ā¦
Not sure if that helps you ā¦ but works well for us.
Hereās a way to pull in from the images Epicor stores in the database (which is what it looks like youāre trying to do) and bind them to an EpiPictureBox. Be sure to add the references at the top.
using Erp.Adapters;
using System.Drawing;
using System.IO;
private void DisplayImage (string imageID)
{
//instantiate the adapter
using (ImageAdapter ia = new ImageAdapter(this.oTrans))
{
//connect
ia.BOConnect();
try
{
if (ia.ExistsImageID(imageID) && ia.GetByID(imageID)) //make sure the ImageID is valid
{
//the image content is a Base64 encoded string
//convert the string to an image and assign it to the picture box
epiPictureBoxC1.Image = Base64ToImage((string)ia.ImageData.Image.Rows[0]["ImageContent"]);
}
else
EpiMessageBox.Show("Invalid ImageID");
}
catch (Exception ex) { ExceptionBox.Show(ex); }
}
}
private Image Base64ToImage(string base64String)
{
// Convert base 64 string to byte[]
byte[] imageBytes = Convert.FromBase64String(base64String);
// Convert byte[] to Image
using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
{
Image image = Image.FromStream(ms, true);
return image;
}
}
I have this code and I am getting the first Message Box about āStarting BAsic Imageā, then I get the second Message Box of āImage IDā. and then voilaā¦nothing shows in the Picture Box. So, Iām wondering what I am doing wrong?
I am trying to do something similar in a dashboard customization, I put the code behind a button to test it, but I get this error when I try to compile:
Error: CS0708 - line 61 (125) - āepiButton1_Clickā: cannot declare instance members in a static class
Thanks Shannon, I got the reference sorted, I updated my original question with my current issue now. Basic c# I am sure just canāt work out, itās this that causes the error ImageAdapter(this.oTrans)?