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 sende开发者_如何转开发r, EventArgs e)
{
LoadRecords();
Image.FromFile("@ C:\Users\cAndyb0eMeh\Documents\Downloads\images.jpeg");
}
But this doesn't work. I get errors.
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");
}
you have to use "\\" for mentioning the path.
pictureBox1.Image = Image.FromFile"c:\\Users\cAndyb0eMeh\\Documents\\Downloads\\images.jpeg");
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.
精彩评论