.net上課作業,還是滿簡單的。
附上控件的代碼:
/////控件的timer計時器事件/////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace timer
{
public partial class showtime : UserControl
{
public showtime()
{
InitializeComponent();
this.timer1.Start(); //啟動計時器
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = System.DateTime.Now.ToString()+":"+System.DateTime.Now.Millisecond.ToString();;
}
public int timerate //設置屬性
{
get { return this.timer1.Interval; }
set { this.timer1.Interval = value; }
}
}
}