hey folks,
i have a button named btnnext and a picturebox pbox . On the click of the next button i want that picturebox should display image one by one on the next button click.. how to do this ??
pl give me idea...plz....
hey folks,
i have a button named btnnext and a picturebox pbox . On the click of the next button i want that picturebox should display image one by one on the next button click.. how to do this ??
pl give me idea...plz....
public partial class Form1 : Form
{
int index = -1;
List<Image> images;
public Form1()
{
InitializeComponent();
images = new List<Image>();
// add images
}
private void btnNext_Click(object sender, EventArgs e)
{
index++;
if (index < 0 || index >= images.Count)
index = 0;
pictureBox1.Image = images[index];
}
}
thanks for your help...but where should i give the path of the folder ?? or how to write it ?
public partial class Form1 : Form { int index = -1; List<Image> images; public Form1() { InitializeComponent(); images = new List<Image>(); // add images } private void btnNext_Click(object sender, EventArgs e) { index++; if (index < 0 || index >= images.Count) index = 0; pictureBox1.Image = images[index]; } }
hii thanks for ur reply...but i am gettting this error : 'Image' is a 'namespace' but is used like a 'type'
Secondly, where i give the path of the folder of images ??? n how ?
kindly awating ur reply...
cya
Rohan
public partial class Form1 : Form { int index = -1; List<Image> images; public Form1() { InitializeComponent(); images = new List<Image>(); // add images } private void btnNext_Click(object sender, EventArgs e) { index++; if (index < 0 || index >= images.Count) index = 0; pictureBox1.Image = images[index]; } }
thanks for your help...but where should i give the path of the folder ?? or how to write it ?
List<Image> images = new List<Image>();
DirectoryInfo di = new DirectoryInfo(@"c:\myimages"); // give path
FileInfo[] finfos = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
foreach (FileInfo fi in finfos)
images.Add(Image.FromFile(fi.FullName));
thanks hope it works but ...I am getting Error : 'Image' is a 'namespace' but is used like a 'type' how to get rid of this ??
cya
Rohan
List<Image> images = new List<Image>(); DirectoryInfo di = new DirectoryInfo(@"c:\myimages"); // give path FileInfo[] finfos = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly); foreach (FileInfo fi in finfos) images.Add(Image.FromFile(fi.FullName));
thanks hope it works but ...I am getting Error : 'Image' is a 'namespace' but is used like a 'type' how to get rid of this ??
cya
Rohan
Which line gives you that error?
I found out the problem...it was namespace clash...nuthin else.....Thanks the problem is solved ! cheersssss
cya
Rohan
Which line gives you that error?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.