把鼠标放到窗体上,会触发窗体的 鼠标悬浮事件,想问一下,内部是怎么实现的,需要监听器吗?

解决方案 »

  1.   

    比如说一个label标签,有单击事件,怎样产生的单击事件,我自己做了个控件,怎么让他产生单击事件,或者是鼠标悬浮事件。谢谢接打,,,,,
      

  2.   


    这个前提是label是个控件,有单击事件,而我自己做的控件,事先并没有单击事件,我想做个单击事件,或者是鼠标悬浮事件,不知道该怎么做。
      

  3.   

    //定义事件参数
    public sealed class CustomEventArgs : EventArgs
    {
        ...
    }// 定义委托
    public delegate void CustomEventHandler(object sender, CustomEventArgs e);// 创建事件
    public event CustomEventHandler Custom;//执行事件
    protected virtual void OnCustom(CustomEventArgs e)
    {
        if (Custom != null)
        {
            Custom(this, e);
        }
    }最后就是在你的代码中合适的位置执行OnCustom触发事件了
      

  4.   

    如何添加事件响应啊,就像windows控件一样,有各种各样的事件
      

  5.   

    微软的控件是怎么开发出来的,比如说label标签,按钮button
      

  6.   

    用一个Label控件,图像画在Label上,Label支持鼠标事件.
      

  7.   

    把你做的空间放DIV里 他有很多事件  <div onmouseout ="out(id)" onmouseover ="over(id)"> function   over(id)
     {
     document.getElementById(id).style.backgroundColor="#99cc66";
     }
      function   out(id)
     {
     document.getElementById(id).style.backgroundColor="#99ffcc";
     }
      

  8.   


    你们说的也可以,权宜之计,我想开发一个全新的控件,就像lable,button,呢样,有自己的属性,事件,该怎么做呢
      

  9.   

    Label 控件public class Label : Control
    {
        // Fields
        private bool controlToolTip;
        private static readonly object EVENT_TEXTALIGNCHANGED = new object();
        private BitVector32 labelState = new BitVector32();
        private static readonly int PropImage = PropertyStore.CreateKey();
        private static readonly int PropImageAlign = PropertyStore.CreateKey();
        private static readonly int PropImageIndex = PropertyStore.CreateKey();
        private static readonly int PropImageList = PropertyStore.CreateKey();
        private static readonly int PropTextAlign = PropertyStore.CreateKey();
        private int requestedHeight;
        private int requestedWidth;
        internal bool showToolTip;
        private static readonly BitVector32.Section StateAnimating = BitVector32.CreateSection(1, StateAutoSize);
        private static readonly BitVector32.Section StateAutoEllipsis = BitVector32.CreateSection(1, StateBorderStyle);
        private static readonly BitVector32.Section StateAutoSize = BitVector32.CreateSection(1, StateUseMnemonic);
        private static readonly BitVector32.Section StateBorderStyle = BitVector32.CreateSection(2, StateFlatStyle);
        private static readonly BitVector32.Section StateFlatStyle = BitVector32.CreateSection(3, StateAnimating);
        private static readonly BitVector32.Section StateUseMnemonic = BitVector32.CreateSection(1);
        private LayoutUtils.MeasureTextCache textMeasurementCache;
        private ToolTip textToolTip;    // Events
        [EditorBrowsable(EditorBrowsableState.Always), SRCategory("CatPropertyChanged"), SRDescription("ControlOnAutoSizeChangedDescr"), Browsable(true)]
        public event EventHandler AutoSizeChanged
        {
            add
            {
                base.AutoSizeChanged += value;
            }
            remove
            {
                base.AutoSizeChanged -= value;
            }
        }    [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public event EventHandler BackgroundImageChanged
        {
            add
            {
                base.BackgroundImageChanged += value;
            }
            remove
            {
                base.BackgroundImageChanged -= value;
            }
        }    [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public event EventHandler BackgroundImageLayoutChanged
        {
            add
            {
                base.BackgroundImageLayoutChanged += value;
            }
            remove
            {
                base.BackgroundImageLayoutChanged -= value;
            }
        }    [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public event EventHandler ImeModeChanged
        {
            add
            {
                base.ImeModeChanged += value;
            }
            remove
            {
                base.ImeModeChanged -= value;
            }
        }    [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public event KeyEventHandler KeyDown
        {
            add
            {
                base.KeyDown += value;
            }
            remove
            {
                base.KeyDown -= value;
            }
        }    [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public event KeyPressEventHandler KeyPress
        {
            add
            {
                base.KeyPress += value;
            }
            remove
            {
                base.KeyPress -= value;
            }
        }    [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
        public event KeyEventHandler KeyUp
        {
            add
            {
                base.KeyUp += value;
            }
            remove
            {
                base.KeyUp -= value;
            }
        }    [EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
        public event EventHandler TabStopChanged
        {
            add
            {
                base.TabStopChanged += value;
            }
            remove
            {
                base.TabStopChanged -= value;
            }
        }    [SRCategory("CatPropertyChanged"), SRDescription("LabelOnTextAlignChangedDescr")]
        public event EventHandler TextAlignChanged
        {
            add
            {
                base.Events.AddHandler(EVENT_TEXTALIGNCHANGED, value);
            }
            remove
            {
                base.Events.RemoveHandler(EVENT_TEXTALIGNCHANGED, value);
            }
        }
    ……
      
      

  10.   

    你可以 看下 Reflector.exe 上控件的代码
      

  11.   

    控件开发是不是要继承form窗体