【发布时间】:2015-12-24 07:29:36
【问题描述】:
嗨,我正在尝试制作一个面板,当它悬停在图片上时会显示一些文本,我希望它跟随光标,所以我
System.Windows.Forms.Panel pan = new System.Windows.Forms.Panel();
public Form1()
{
InitializeComponent();
Product p = new Product();
p.SetValues();
this.pictureBox1.Image = (Image)Properties.Resources.ResourceManager.GetObject("pictureName");
}
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
pan.Height = 200;
pan.Width = 100;
pan.BackColor = Color.Blue;
this.Controls.Add(pan);
pan.BringToFront();
//pan.Location = PointToClient(Cursor.Position);
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
Controls.Remove(pan);
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
pan.Location = PointToClient(Cursor.Position);
}
我尝试添加this.doublebuffered = true;
但它只是让它看起来像当我移动鼠标时有面板的后图像
当我将鼠标悬停在我的图片上时,它会显示面板,但它会疯狂地闪烁 这是正常的还是有解决方法或者这是我的电脑问题
【问题讨论】:
-
我假设每次移动鼠标时面板都会重新绘制。也许只使用
MouseHover事件(没有MouseMove)并设置MousHoverTime 以查看它是否正常工作。 -
对不起,我将操作从悬停更改为输入,我只是重用代码
-
我是这么认为的。请编辑问题!
标签: c# panel windows-forms-designer