本帖最后由 xjzhangbowei 于 2010-05-23 02:29:13 编辑

解决方案 »

  1.   

    我想把关机倒计时,获取上,然后显示在自己做的FORM里,请高手多多讲解,麻烦大家讲细一点好吗?
      

  2.   


    还用获取么?
    既然自己写的倒计时time
    那从time开始显示倒计时就好了,不用获取系统上的那个了
      

  3.   

    还用获取么?
    既然自己写的倒计时time
    那从time开始显示倒计时就好了,不用获取系统上的那个了
    [/Quote]怎么显示倒计时呢? 用个timer控件,然后减去自己设定的时间就行了是吧?能不能把那个timer控件减时间的代码 写一下呢?谢谢,呵呵,....上次我提问,也是你回答,这次第一个也是你,有好感了哦...
      

  4.   

    Timer控件倒计时,当计时到0时
    Process.Start("shutdown -s -t 0")
    -t后面的0表示0秒后关机,即倒计时由你决定,时间到了就执行0秒关机
      

  5.   


    怎么显示倒计时呢? 用个timer控件,然后减去自己设定的时间就行了是吧?能不能把那个timer控件减时间的代码 写一下呢?谢谢,呵呵,....上次我提问,也是你回答,这次第一个也是你,有好感了哦...
    [/Quote]
      private int time=60;  
      private void Form1_Load(object sender, System.EventArgs e)  
      {  
      this.label1.Text = string.empty;
      this.timer1.Interval = 1000;  
      this.timer1.Tick += new System.EventHandler(this.timer1_Tick);  
      this.timer1.Start();  
      }  
      private void timer1_Tick(object sender, System.EventArgs e)  
      {  
      if(time>0) {  
      this.label1.Text=time.ToString();  
      time--;  
      }  
      else  
      {  
      timer1.Enabled = false;
      timer1.Stop();  
      return;
      }  
      }
      

  6.   


    private int time=60;  
    private void timer1_Tick(object sender, System.EventArgs e)  
      {  
      if(time>0) {  
      this.label1.Text=time.ToString();  
      time--;  }
      }  
    当time>60的时候,label1.text 开始显示倒计时
    我的意思是:在comboBox1中输入小时,comboBox2中输入分钟,在comboBox3中输入秒,
    然后:
    int time = int.Parse(textBox1.Text.ToString()) * 3600 + int.Parse(textBox2.Text.ToString()) * 60 + int.Parse(textBox3.Text.ToString());
    当time=我自己输入的值时,label1.text开始显示倒计时.
    private int time = int.Parse(textBox1.Text.ToString()) * 3600 + int.Parse(textBox2.Text.ToString()) * 60 + int.Parse(textBox3.Text.ToString());//这样会报错:::无法引用非静态字段private void timer1_Tick(object sender, System.EventArgs e)  
      {  
    /*如果放在这里会说:::将一个字符串转换为DateTime时,先分析该字符串获取日期,然后再将每个变量放置到DateTime中.*/
    private int time = int.Parse(textBox1.Text.ToString()) * 3600 + int.Parse(textBox2.Text.ToString()) * 60 + int.Parse(textBox3.Text.ToString())
      if(time>0) {  
      this.label1.Text=time.ToString();  
      time--;  }
      } 
      

  7.   

    当time>0时,Lable1.text开始显示倒计时,打错了
      

  8.   

    int time = int.Parse(textBox1.Text.ToString()) * 3600 + int.Parse(textBox2.Text.ToString()) * 60 + int.Parse(textBox3.Text.ToString())这段原来放你button4的click里没错,另外private int time=60;  这个全局变量位置不变
      

  9.   


    this.label1.Text = string.empty;
      this.timer1.Interval = 1000;  
      this.timer1.Tick += new System.EventHandler(this.timer1_Tick);  
      this.timer1.Start();
    /*运行后,是以60开始倒计时.把这段代码放进 button4里就对了, 因为只要运行,timer1就开始执行,而下面的
    if(time>0) {  
      this.label1.Text=time.ToString();  
      time--;  
      }  
    time还没有被重新赋值,因为再点击button4之后才会被赋值.
    */谢谢你了,我已经搞定了,能加你Q么?我的 360617172 
      

  10.   

    this.timer1.Tick += new System.EventHandler(this.timer1_Tick);  
    这段代码是什么意思呢?