Load an image

A

Alberto

I'm trying to load an image and show it on a panel control. The code is
this:

private void btnCargarImagen_Click(object sender, System.EventArgs e)

{

openFileDialog1.InitialDirectory = Directory.GetCurrentDirectory();

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{

Image = Image.FromFile(openFileDialog1.FileName);

panelImage.AutoScrollMinSize = Image.Size;

panelImage.Invalidate();

}

}

private void panelImage_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)

{

if (Image != null)

e.Graphics.DrawImage(Image, this.AutoScrollPosition);

}

}



The Image is loaded but when I move the panel's bar, I don't see the image
properly.

Does anybody know what's happening?

Thank you very much
 
A

Alberto

I respond myself: the error was in this line
this.AutoScrollPosition
I have to change this by panelImage.

Anyway now I can move the image with the bars but I can't see it complete.
Any idea?
Thank yor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top