日期:2014-05-18  浏览次数:20794 次

进度条与listview
如何实现 1、进度条每满一次 text_time_slice.Text数字-1(初始值为3)
2、进度条每满一次 listview中的就删除第一行数据。
下面为代码
pba为进度条
list_readY为listview 为5行。
C# code

 private void timerpba_Tick(object sender, EventArgs e)
        {
            
            int n = list_ready.Items.Count;//返回行数
            //text_time_slice.Text = n.ToString();
            pba.Maximum = 3;
            pba.Value = 0;//设置当前值
            pba.Step = 1;//设置没次增长多少
            for (int m = 0; m < n; m++)//进度满值的循环的次数
            {
                for (int j = 0; j < 3; j++)//循环
                {
                    //text_time_slice.Text = j.ToString();//[color=#FF9900]如何实现进度条加1 text_time_slice.Text中的数就-1?[/color]
                    System.Threading.Thread.Sleep(500);//暂停1秒
                    pba.Value += pba.Step;//让进度条增加一次
                    //for();
                    // timerpba.Enabled = true;

                }

                if (this.pba.Value == 3)
                {


                    //text_time_slice.Text = i.ToString();

                    System.Threading.Thread.Sleep(500);//进度条满后停顿0.5秒后继续循环
                    list_ready.Items.Remove(1);//[color=#FF0000]如何在此时删除listview的第一行??????[/color]
                    pba.Value = 3;
                    pba.Value = 0;
                    
                    //pba.PerformStep();
                }
            }timerpba.Enabled = false;
        }



------解决方案--------------------
C# code
private void timerpba_Tick(object sender, EventArgs e)
        {
            
            int n = list_ready.Items.Count;//返回行数
            text_time_slice.Text = n.ToString();
            pba.Maximum = 3;
            pba.Value = 0;//设置当前值
            pba.Step = 1;//设置没次增长多少
            for (int m = 0; m < n; m++)//进度满值的循环的次数
            {
                for (int j = 0; j < 3; j++)//循环
                {
                    text_time_slice.Text = Convert.ToInt32(t_time_slice.Text)-1;
                  System.Threading.Thread.Sleep(500);//暂停1秒
                    pba.Value += pba.Step;//让进度条增加一次
                    //for();
                    // timerpba.Enabled = true;

                }

                if (this.pba.Value == 3)
                {


                    //text_time_slice.Text = i.ToString();

                    System.Threading.Thread.Sleep(500);//进度条满后停顿0.5秒后继续循环
                    if(list_ready.Items.Count>0)
                  {
                    list_ready.Items.Remove(0);
                  }
                    pba.Value = 3;
                    pba.Value = 0;
                    
                    //pba.PerformStep();
                }
            }timerpba.Enabled = false
}