日期:2014-05-17  浏览次数:20826 次

自定义控件的事件
最近在学习自定义控件,参考网上的文章和代码写了一个控件,希望在达到定时时间是引发一个事件,现在的问题是:到时间后,事件不能引发。代码如下:

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;
using System.Drawing.Drawing2D;

//
using System.Timers;

//

namespace WindowsFormsControlLibrary1

{
    [ToolboxBitmap(typeof(System.Windows.Forms .Timer))]

    public partial class Clocks : UserControl
    {
        public event EventHandler Clocks_TimerEvent;//定义事件



        private DateTime Time;
        private Color colFColor;
        private Color colBColor;
        public Pen HPn;
        public Pen MPn;
        public Pen SPn;

        public int HW;
        public int MW;
        public int SW;

        public Boolean BL;
        public String  DT;
        public DateTime XTS;

        public Image FImageFil;

        public Color ClockFColor;
        //public Color ClockBColor;
        public Clocks()
        {
            InitializeComponent();
            this.HourColor = Color.Red;//给属性赋初值
            this.MinoutColor =Color .Blue ;
            this.SecondColor  = Color.Black;
            this.HW =1;
            BL = false;
            DT ="1900-02-21 12:23:33";