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

2021-05-15 20:28

阅读:417

标签:sele   col   false   leave   contains   rgba   sel   bounds   定义   

实现了提示控件(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();
}

 

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

标签:sele   col   false   leave   contains   rgba   sel   bounds   定义   

原文地址:https://www.cnblogs.com/z5337/p/14674831.html


评论


亲,登录后才可以留言!