I am working on a windows form application.
I want a image slider to be displayed at the bottom of my windows application, something like this:
Image slide example
Image paths would be grabbed from a DB. Any idea how to implement this?
Thanks in advance :)
I don't know if you want a slider that shows only one picture at a time or more, but you can adapt the code if you need the latter.
private void showImage(string path)
{
Image imgtemp = Image.FromFile(path);
pictureBox1.Width = imgtemp.Width / 2;
pictureBox1.Height = imgtemp.Height / 2;
pictureBox1.Image = imgtemp;
}
If you want it to work only on an automated mode, use only one method:
private void prevImage()
{
if(selected == 0)
{
selected = folderFile.Length - 1;
showImage(folderFile[selected]);
}
else
{
selected = selected - 1; showImage(folderFile[selected]);
}
}
private void nextImage()
{
if(selected == folderFile.Length - 1)
{
selected = 0;
showImage(folderFile[selected]);
}
else
{
selected = selected + 1; showImage(folderFile[selected]);
}
}
Now the timer and the start slideshow button:
private void timer1_Tick(object sender, System.EventArgs e)
{
nextImage();
}
private void Start_Click(object sender, System.EventArgs e)
{
if(timer1.Enabled == true)
{
timer1.Enabled = false;
Start.Text = "<< START Slide Show >>";
}
else
{
timer1.Enabled = true;
Start.Text = "<< STOP Slide Show >>";
}
}
From here . However, if you need something more than this you can read check ImageSlider from devexpress .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.