如何用C#制作图片浏览按钮

来源:百度知道 编辑:UC知道 时间:2024/05/29 23:21:37
想做一个图片浏览器,就是有上一页、下一页二个功能:
但是浏览到第一张或最后一张的时候,我设置按钮控件属性值为false
当我点了上一页后,再去点下一页就报错了!我想可能是index值没有随着变的原因,不知道怎么改了,小弟刚学,请多指教!附上代码:
int index=0;
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (index< 0 )
{
toolStripButton1.Enabled = false;
//index = imageList1.Images.Count;
//MessageBox.Show("已经是第一张了", "提示");
}
else
{
pictureBox1.Image = imageList1.Images[index];
index--;
}
}
private void toolStripButton2_Click(object sender, EventArgs e)
{
if (index >= imageList1.Images.Count)
{
toolStripButton2.Enabled = false;
}
else
{
pictureBo


设置个全局变量 bool isStop=falsh;



if(!isStop)
{
timer1.Start();
isStop=true;
button1.Text="开始";
}
else
{
timer1.Stop();
isStop=falsh;
button1.Text="停止";
}

这里的timer1是你设置的tiemr控件名字 或自己定义timer的名字
button1是你的button名称

上面一段放在你要实现此功能的按钮Click事件里面