当鼠标移动到用户控件上时把button显示出来。移出时隐藏button。
我现在用用户控件的mouseenter和mouseleave事件来实现的。mouseenter的时候把button的visable设成true,mouseleave的时候设为false,但是有个问题,当鼠标移动到button上时用户控件的mouseleave事件也会触发将butoon给隐藏起来了。应该如何解决这个问题啊?

解决方案 »

  1.   

    使用消息里判断鼠标位置来解决把..当你鼠标移动到Button里也会触发 父控件的 mouseleave
    你可以在OnPaint里加判断 不使用mouseenter和mouseleave
      

  2.   


    当鼠标移动到button上时用户控件的mouseleave事件也会触发
    此时再判断一下,如果是进入button就什么都不做。
      

  3.   

      <div onmouseover="document.getElementById('s').style.display='';" onmouseout="document.getElementById('s').style.display='none';" style=" width: 200px; height: 200px; background-color: red;">
    <input id="s" type="button" text="submit" style="display: none; margin: 20px;" />
      </div>
      

  4.   

    说说我的想法:在MouseEnter的时候,设置Capture为true,处理MouseMove事件,判断鼠标当前坐标是否在用户控件范围内,当鼠标移出用户控件的时候,设置Capture为false。
      

  5.   

    你也可以设定在鼠标移出多少秒后在隐藏Button,这样当你鼠标移到Button上的时候你可以在进行处理
      

  6.   

    当鼠标移动到button上时用户控件的mouseleave事件也会触发 
    此时再判断一下,如果是进入button就什么都不做。

    这样就可以了