hi,
There is a pictureBox on a windows form.
In design mode, the image is set to pick up a .bmp file from the local machine.
I would like to click on this image and another image to appear instead in the same location.
in other words, the image of the same PictureBox changes.
What should i put in the click event to pick up another .bmp for the image
Thanks

picturebox
rjperes
_picturebox.Image = Image.FromFile("someimage.bmp")
If the bmp is in the resources
_picturebox.Image = Image.FromStream([GetType].Assembly.GetManifestResourceStream(GetType(Me), "image.bmp"))
sushant.pandey
There is a pictureBox on a windows form.
The image is set to pick up a file when the form is shown.
On each click on the pictureBox, the image should change.
When the form is shown, the image of the pictureBox is shown (padlock).
then when the pictureBox is clicked the first time, the image changes to closed padlock.
But when the pictureBox is clicked again, the image does not change.
Please see the code below.
Thanks
private const string imagePath = @"F:\Projects\images\";
private const string padLockClosed = imagePath + "PadlockClosed.bmp";
private const string padLockOpen = imagePath + "PadlockOpen.bmp";
private void AssignPadLockImage()
{
if (telephonePictureBox.Image == Image.FromFile(padLockClosed))
{
telephonePictureBox.Image = Image.FromFile(padLockOpen);
}
else
{
telephonePictureBox.Image = Image.FromFile(padLockClosed);
}
}
private void telephonePictureBox_Click(object sender, System.EventArgs e)
{
AssignPadLockImage();
if (telephoneTextBox.ReadOnly == true)
{
telephoneTextBox.ReadOnly = false;
}
else
{
telephoneTextBox.ReadOnly = true;
}
}
jhansenx
private void AssignPadLockImage()
{
if (_closed)
{
telephonePictureBox.Image = Image.FromFile(padLockOpen);
_closed = false;
}
else
{
telephonePictureBox.Image = Image.FromFile(padLockClosed);
_closed = true;
}
}
or maybe in your case you could compare it with the telephoneTextBox.ReadOnly