欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門(mén)教程網(wǎng)!

C#教程

當(dāng)前位置:主頁(yè) > 軟件編程 > C#教程 >

C#中數(shù)據(jù)的傳遞以及ToolStripProgressBar

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C#教程|點(diǎn)擊: 次

代碼:

方法一:窗體的代碼-->可以直接通過(guò)預(yù)設(shè)的Click事件來(lái)實(shí)現(xiàn)控制進(jìn)度條。

public partial class Form1 : Form
 { 
  public Form1()
  {
   InitializeComponent();
   toolStripProgressBar_save.Minimum = 0;
   toolStripProgressBar_save.Maximum = 100;
   toolStripProgressBar_save.Step = 5;
  }
  #region 不涉及數(shù)據(jù)傳輸
  private void button_10_Click(object sender, EventArgs e)
  {
   //清空進(jìn)度表
   toolStripProgressBar_save.Value = 0;
   if(toolStripProgressBar_save.Value<10)
   {
    for (int i=0;i<2;i++)
    {
     toolStripProgressBar_save.PerformStep();
     toolStripLabel_save.Text = toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
  }
  private void button_30_Click(object sender, EventArgs e)
  {
   if (toolStripProgressBar_save.Value < 30)
   {
    for(int i=0;i<4;i++)
    {
     toolStripProgressBar_save.PerformStep();
    }
   }
   toolStripLabel_save.Text = "30%";
  }
  private void button_50_Click(object sender, EventArgs e)
  {
   if (toolStripProgressBar_save.Value < 50)
   {
    for (int i = 0; i < 4; i++)
    {
     toolStripProgressBar_save.PerformStep();
    }
   }
   toolStripLabel_save.Text = "50%";
  }
  private void button_60_Click(object sender, EventArgs e)
  {
   if (toolStripProgressBar_save.Value < 60)
   {
    for (int i = 0; i < 2; i++)
    {
     toolStripProgressBar_save.PerformStep();
    }
   }
   toolStripLabel_save.Text = "60%";
  }
  private void button_80_Click(object sender, EventArgs e)
  {
   if (toolStripProgressBar_save.Value < 80)
   {
    for (int i = 0; i < 4; i++)
    {
     toolStripProgressBar_save.PerformStep();
    }
   }
   toolStripLabel_save.Text = "80%";
  }
  private void button_100_Click(object sender, EventArgs e)
  {
   if (toolStripProgressBar_save.Value < 100)
   {
    for (int i = 0; i < 4; i++)
    {
     toolStripProgressBar_save.PerformStep();
    }    
   }
   toolStripLabel_save.Text = "Complete!";
  }
  #endregion
  private void button_save_Click(object sender, EventArgs e)
  {
   Save.Singleton().SaveAll();
  }
 }

方法二:通過(guò)調(diào)用其他類里的方法來(lái)實(shí)現(xiàn)對(duì)進(jìn)度條的控制。

注意一:需要using System.Windows.Forms;

注意二:進(jìn)度條ToolStripProgressBar的權(quán)限需要改成Public

public class Save
 {
  private static Save _instance = null;
  private Form1 n = null;
  public void SaveAll()
  {
   getWnd();
   n.toolStripProgressBar_save.Minimum = 0;
   n.toolStripProgressBar_save.Maximum = 100;
   //清空進(jìn)度表
   n.toolStripProgressBar_save.Value = 0;
   n.toolStripProgressBar_save.Step = 5;
   #region 保存過(guò)程-與單獨(dú)按鈕是一樣的
   if (n.toolStripProgressBar_save.Value < 10)
   {   
    for (int i = 0; i < 2; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
   Thread.Sleep(1000);
   if (n.toolStripProgressBar_save.Value < 30)
   {
    for (int i = 0; i < 4; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString()+"%";
    }
   }
   Thread.Sleep(100);
   if (n.toolStripProgressBar_save.Value < 50)
   {
    for (int i = 0; i < 4; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
   Thread.Sleep(100);
   if (n.toolStripProgressBar_save.Value < 60)
   {
    for (int i = 0; i < 2; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
   Thread.Sleep(100);
   if (n.toolStripProgressBar_save.Value < 80)
   {
    for (int i = 0; i < 4; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
   Thread.Sleep(100);
   if (n.toolStripProgressBar_save.Value < 100)
   {
    for (int i = 0; i < 4; i++)
    {
     n.toolStripProgressBar_save.PerformStep();
     n.toolStripLabel_save.Text = n.toolStripProgressBar_save.Value.ToString() + "%";
    }
   }
   n.toolStripLabel_save.Text = "Complete!";
   Thread.Sleep(100);
   #endregion
  }
  //查找當(dāng)前打開(kāi)的窗體,必須有這個(gè)才能傳遞數(shù)據(jù)
  private void getWnd()
  {
   foreach(Form fm in Application.OpenForms)
   {
    if (fm.Name == "Form1")
    {
     n = (Form1)fm;
     break;
    }
   }
  }
  public static Save Singleton()
  {
   if (_instance == null)
   {
    _instance = new Save();
   }
   return _instance;
  }
 }

 

效果圖:(左邊為方法一的效果、右邊為方法二的效果圖)

   

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有