Abid
Abid

Reputation: 133

how to add a picture onto the interface..?

I want to display a picture that is of jpeg type onto my interface. I want that picture to be displayed when my program is being executed. I'm doing this:

private void frmMain_Load(object sender, EventArgs e)
{
     LoadRecords();
     Image.FromFile("@ C:\Users\cAndyb0eMeh\Documents\Downloads\images.jpeg");        
} 

But this doesn't work. I get errors.

Upvotes: 0

Views: 574

Answers (3)

codekaizen
codekaizen

Reputation: 27419

You'll need somewhere to put that picture, like a PictureBox control. You can one to your form from Visual Studio's ToolBox. When you add one, it is named PictureBox1 by default. So, in your form load event, you'd have:

PictureBox1.Image = Image.FromFile("@ C:\Users\cAndyb0eMeh\Documents\Downloads\images.jpeg");

The way you're doing it now, the image doesn't go anywhere.

Upvotes: 0

Pavan Navali
Pavan Navali

Reputation: 242

you have to use "\\" for mentioning the path.

pictureBox1.Image = Image.FromFile"c:\\Users\cAndyb0eMeh\\Documents\\Downloads\\images.jpeg");

Upvotes: 0

Naeem Sarfraz
Naeem Sarfraz

Reputation: 7430

Try this (your @ is in the wrong place):

private void frmMain_Load(object sender, EventArgs e) { 
 LoadRecords();      
 pictureBox1.Image = Image.FromFile(@"C:\Users\Andy Meh\Documents\Downloads\images.jpeg");
}

Upvotes: 3

Related Questions