[转][C#]自定义提示控件

时间:2021-04-20 15:36:30   收藏:0   阅读:0

实现了提示控件(picture1)随着鼠标而移动,但点击时仍会显示(是一个BUG)

需要绑定事件到 form、panel1、picture1、等控件

private void panel1_MouseMove(object sender, MouseEventArgs e)
{
    //timer1.Start();
    var p = PointToClient(MousePosition);
    Debug.WriteLine("MouseMove.{0},{1}", p.X, p.Y);
    pictureBox1.Location = p;
    pictureBox1.Show();
}

private void panel1_MouseLeave(object sender, EventArgs e)
{
    //pictureBox1.Visible = false;
    var p = PointToClient(MousePosition);
    Debug.WriteLine("MouseLeave.{0},{1}", p.X, p.Y);
    if (panel1.Bounds.Contains(p) || button1.Bounds.Contains(p))
    {
        //pictureBox1.Location = p;
        //pictureBox1.Show();
    }
    else
        pictureBox1.Hide();
}

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!