有基本的Windows窗體應用程序一點點代碼我寫的。但有些事情出錯了。我開始的應用程序,一切都很好,但如果我啓動計時器,它的第一次運行,不重複。我該怎麼辦?的Visual C#計時器不滴答
對不起,語法錯誤。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
namespace Zamanlayıcı
{
public partial class Form1 : Form
{
public int saat;
public int dakika;
public int saniye;
public int zaman;
public Form1()
{
InitializeComponent();
}
private void baslat_button_Click(object sender, EventArgs e)
{
timer1.Interval = 1000;
timer1.Start();
}
private void durdur_button_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void demizle_button_Click(object sender, EventArgs e)
{
saat_box.Clear();
dakika_box.Clear();
saniye_box.Clear();
zaman_text.Text = "00:00:00";
}
private void ses_checkbox_CheckedChanged(object sender, EventArgs e)
{
}
private void timer1_Tick_1(object sender, EventArgs e)
{
int saat = int.Parse(saat_box.Text);
int dakika = int.Parse(dakika_box.Text);
int saniye = int.Parse(saniye_box.Text);
int zaman = saat * 60 * 60 + dakika * 60 + saniye;
int saat2 = zaman/60/60;
int dakika2 = zaman/60 % 60;
int saniye2 = zaman % 60;
if(zaman > 0) {
zaman--;
zaman_text.Text = saat2.ToString("00") + ":" + dakika2.ToString("00") + ":" + saniye2.ToString("00");
}if(zaman == 0)
{
MessageBox.Show("Zaman doldu!", "Bitti", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
檢查以確保當我按下啓動按鈕的設置文本Tick事件勢必timer1_Tick_1 – Trey
,但不重複所以我確定它必然正確的事件 –
什麼是文本在那點..你有沒有在tick事件中放置一個斷點? – Trey