i want to put an image to a picturebox when i click a button, the iage does not apear
this is the code i'm using:
private Bitmap MyImage ;
private void button9_Click(object sender, System.EventArgs e)
{
// Sets up an image object to be displayed.
if (MyImage != null){
MyImage.Dispose();
}
//openFileDialog1.ShowDialog();MyImage =
new Bitmap(@"c:\temp\print.bmp");pictureBox1.Image = (Image) MyImage ;
pictureBox1.Refresh();
}
can someone help....
Jorge Rodrigues
Mike GoldPosted Aug 6, 2006, 1:23 PM
Just tried it myself. I don't think you need to refresh. Here is the code i used:
using
System.Drawing;using
System.Text;using
System.Windows.Forms;namespace
TestPictureBox{
public partial class Form1 : Form{
public Form1(){
InitializeComponent();
pictureBox1.Image = null;
private void button1_Click(object sender, EventArgs e)}
{
if (pictureBox1.Image == null)
new Bitmap("test.jpg");{
pictureBox1.Image =
}
}
}
}