| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3865 人关注过本帖
标题:c# winfrom panel 的mouseleave怎么用啊
只看楼主 加入收藏
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:0 
透明不是用这个panel1.Visible = false;

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-09-24 17:09
zhoufeng1988
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:北京
等 级:贵宾
威 望:27
帖 子:1432
专家分:6329
注 册:2009-5-31
收藏
得分:0 
看看行不行..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MouseMoveAndMouseLeave
{
   
public partial class Form1 : Form
   
{
        
private bool isMouseInPanel;
        
private bool isMouseInButton;
        
public event EventHandler OnMouseLeavePanelRegion;

        
public Form1()
        
{
            
InitializeComponent();
            
this.panel1.BorderStyle = BorderStyle.Fixed3D;
            
this.isMouseInButton = true;
            
this.isMouseInPanel = false;

            
this.panel1.MouseLeave += new EventHandler(panel1_MouseLeave);
            
this.panel1.MouseEnter += new EventHandler(panel1_MouseEnter);
            
this.button1.MouseEnter += new EventHandler(button1_MouseEnter);
            
this.button1.MouseLeave += new EventHandler(button1_MouseLeave);
            
this.OnMouseLeavePanelRegion += new EventHandler(Form1_OnMouseLeavePanelRegion);
        
}

      
void button1_MouseLeave(object sender, EventArgs e)
        
{
            
this.isMouseInButton = false;
        
}

        
void Form1_OnMouseLeavePanelRegion(object sender, EventArgs e)
        
{
            
if (!this.isMouseInButton && !this.isMouseInPanel)
            
{
               
this.panel1.Visible = false;
            
}
        
}

        
void button1_MouseEnter(object sender, EventArgs e)
        
{
            
this.isMouseInButton = true;
        
}

        
void panel1_MouseEnter(object sender, EventArgs e)
        
{
            
this.isMouseInPanel = true;
            
this.OnMouseLeavePanelRegion(null, null);
        
}

        
void panel1_MouseLeave(object sender, EventArgs e)
        
{
            
this.isMouseInPanel = false;
            
this.OnMouseLeavePanelRegion(null, null);
        
}

   
}
}

 
2009-09-24 17:21
zhwbo123789
Rank: 2
等 级:论坛游民
帖 子:25
专家分:23
注 册:2009-3-23
收藏
得分:0 
呵呵 谢谢12楼的 要的就是这效果
2009-09-24 17:28
zhoufeng1988
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:北京
等 级:贵宾
威 望:27
帖 子:1432
专家分:6329
注 册:2009-5-31
收藏
得分:0 
那个有问题..

换个方法试试

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace MouseMoveAndMouseLeave
{
   
public partial class Form1 : Form
   
{
        
private bool isMouseInPanel;
 
        
public Form1()
        
{
            
InitializeComponent();
            
this.panel1.BorderStyle = BorderStyle.Fixed3D;
            
this.isMouseInPanel = false;
            
this.panel1.MouseEnter += new EventHandler(panel1_MouseEnter);
        
}
 
        
void panel1_MouseEnter(object sender, EventArgs e)
        
{
            
this.MouseEnter += new EventHandler(Form1_MouseEnter);
        
}
 
        
void Form1_MouseEnter(object sender, EventArgs e)
        
{
            
this.panel1.Visible = false;
        
}
   
}
}
收到的鲜花
  • zhwbo1237892009-09-28 09:01 送鲜花  3朵   附言:我很赞同
2009-09-24 17:47
快速回复:c# winfrom panel 的mouseleave怎么用啊
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016750 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved