Your problem is that you're setting brPicsArray
to btnClick % brPicsArray
, which will eventually equal 0
.
Instead, you should use something like:
switch (brPicsArray % btnClick) {
case 0:
...
}
Note: We're starting with a case index of 0, which is more standard, and we're not changing the value of brPicsArray
.
I would encourage you to store your image names in an array instead and use the array's Count
property instead of a separately stored variable. In that case, you'd end up with something more like:
public partial class Form3 : Form {
string[] imageFilenames = new string[] {
"C:\Users\Korice\Documents\Visual Studio 2012\Projects\.....\form3pic1.jpg",
"C:\Users\Korice\Documents\Visual Studio 2012\Projects\.....\form3pic2.jpg",
"C:\Users\Korice\Documents\Visual Studio 2012\Projects\.....\form3pic3.jpg",
"C:\Users\Korice\Documents\Visual Studio 2012\Projects\.....\form3pic4.jpg",
"C:\Users\Korice\Documents\Visual Studio 2012\Projects\.....\form3pic5.jpg",
};
int btnClick=0;
private void button1_Click(object sender, EventArgs e) {
btnClick++;
pictureBox1.Image = Image.FromFile(imageFilenames[imageFilenames.Count % btnClick]);
}
}