Load an image

  • Thread starter Thread starter Alberto
  • Start date Start date
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
 
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.
 
Back
Top