MonthCalendar上使ToolTip随鼠标位置实时变化

来源:互联网 发布:windows phone8.1更新 编辑:程序博客网 时间:2024/05/02 06:13

想写一个在日历上的实时提醒功能,即在鼠标滑动到某一天时提示相应信息。

MonthCalendar上监视MouseMove事件

开始遇到的问题是实时刷新时会使界面刷新变慢,即MouseMove事件会连续触发,至今不明原理。。。(可能是因为ToolTip的刷新会触发鼠标时间吧。。。)

修改为如下判断鼠标坐标后可正常使用。

 

private void monthCalendar1_MouseMove123(object sender, MouseEventArgs e)        {            if (p == Cursor.Position)            {                return;            }            else            {                p = new Point(Cursor.Position.X, Cursor.Position.Y);            }            MonthCalendar.HitTestInfo info = this.monthCalendar1.HitTest(e.Location);            string s = tp.GetToolTip(this.monthCalendar1);            //if (s.Equals(info.Time.ToString()))            //{                //tp.Show(info.Time.ToString(), this.monthCalendar1, new Point(e.X, e.Y));                //return;           // }            //else            {                tp.SetToolTip(this.monthCalendar1, info.Time.ToString());            }        }


 

0 0
原创粉丝点击