Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#使用定时器进行图像旋转_C# - Fatal编程技术网

C#使用定时器进行图像旋转

C#使用定时器进行图像旋转,c#,C#,我是使用WFA的初学者C#用户。下面是我的代码,让图像每4个刻度旋转一次。请允许我对我可能做得不正确的事情提供一些帮助 private void timer1_Tick(object sender, EventArgs e) { int time = 0; int pic = 0; { if (time >= 4) pic++; this.picBox1.Image = ImageList.Images[p

我是使用WFA的初学者C#用户。下面是我的代码,让图像每4个刻度旋转一次。请允许我对我可能做得不正确的事情提供一些帮助

private void timer1_Tick(object sender, EventArgs e)
{
    int time = 0;
    int pic = 0;     

    {
        if (time >= 4)
        pic++;
        this.picBox1.Image = ImageList.Images[pic];
        pic++;
        if (time == 4 || time == 8 || time == 12 || time == 16)
        this.lblCompany.Visible = true;
        this.lsbHistory.ValueMember = ("User Clicks on at ___+ DateTime.Now.ToshortDateString");

每次您的勾号事件被调用时,您都将时间设置为0,这意味着它低于4。您应该将时间和pic值从事件中取出,然后将时间重置为0

我想读一下这个

关于如何使用断点更好地了解代码中发生了什么

private int time = 0;
private int pic = 0; 

private void timer1_Tick(object sender, EventArgs e)
{
     time++;
     if (time >= 4)
     {
          pic++;
          time = 0;
          this.picBox1.Image = ImageList.Images[pic];
          //other logic you might have

您的问题描述不允许很好地理解,代码没有注释,人们被迫猜测您的程序中实际发生了什么。这样一个职位很容易被投票关闭。请尝试添加更多信息