how to change image to another image using picture box
i use picture box control,how to change image to another images in windows form application.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Iftikar HussainPosted Jul 5, 2013, 3:48 AM
Iftikar
Iftikar HussainPosted Jul 5, 2013, 3:48 AM
Iftikar
Dipika ShahPosted Jul 5, 2013, 3:44 AM
not button click event.. picturebox event.
Iftikar HussainPosted Jul 5, 2013, 1:51 AM
You can do as shown below
public partial class Form9 : Form
{
List<string> imageName;
private int counter=0;
public Form9()
{
InitializeComponent();
imageName = new List<string>
{
@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Blue hills.jpg",
@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Sunset.jpg",
@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg",
@"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Winter.jpg"
};
}
private void Form9_Load(object sender, EventArgs e)
{
var image = Image.FromFile(imageName[0]);
pictureBox1.Image = image;
}
private void BtnPrevClick(object sender, EventArgs e)
{
counter = counter - 1;
Image image = Image.FromFile(imageName[counter]);
pictureBox1.Image = image;
if (counter == 0)
{
BtnPrev.Enabled = false;
}
if (counter < imageName.Count)
{
BtnNext.Enabled = true;
}
}
private void BtnNextClick(object sender, EventArgs e)
{
counter = counter + 1;
Image image = Image.FromFile(imageName[counter]);
pictureBox1.Image = image;
if (counter > 0)
{
BtnPrev.Enabled = true;
}
if (counter == imageName.Count-1)
{
BtnNext.Enabled = false;
}
}
}
Regards,
Iftikar
Dipika ShahPosted Jul 5, 2013, 1:28 AM
give me code fast as soon as possible..
Sanjeeb LenkaPosted Jul 4, 2013, 3:32 PM