看板 C_Sharp 關於我們 聯絡資訊
以下為使用Timer 跟 Panel 的程式碼... 可是沒有顯示出我想要的結果 請問是我哪理觀念錯了嗎?? public partial class Form1 : Form { int status; static int x; int y; System.Windows.Forms.Timer myTimer = new System.Windows.Forms.Timer(); static bool exitFlag = false; public Form1() { InitializeComponent(); status = 1; x = 25; y = 25; } private void panel1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen pen = new Pen(Color.Blue); if (status == 0) { g.DrawPie(pen, x, y, 15, 15,0,360); } } private void TimerEventProcessor(Object myObject, EventArgs myEventArgs) { x += 5; myTimer.Stop(); panel1.Invalidate(); myTimer.Enabled = true; if(x==100) { exitFlag = true; } } private void button1_Click(object sender, EventArgs e) { myTimer.Tick += new EventHandler(TimerEventProcessor); myTimer.Interval = 500; myTimer.Start(); while (exitFlag == false) { Application.DoEvents(); } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 124.8.69.235
cole945:你要不要檢查一下status變數.. 04/30 02:00