我有一个具有关联工具提示的picturebox,我想在点击picturebox时显示它,而不是当鼠标悬停在它上面时。我尝试为picturebox创建一个空的MouseHover事件,但是工具提示仍然显示:
private void pictureBox3_MouseHover(object sender, EventArgs e)
{
}
private void pictureBox3_Click(object sender, EventArgs e)
{
int durationMilliseconds = 30000;
toolTip1.Show(toolTip1.GetToolTip(pictureBox3), pictureBox3, durationMilliseconds);
}如果没有在MouseHover上显示工具提示,我可以做什么?
发布于 2017-05-31 08:58:23
不要为pictureBox3设置工具提示(删除它)。给一个人看:
// On class scope to have access from MouseEnter
ToolTip tt = new ToolTip();
private void pictureBox3_Click(object sender, EventArgs e)
{
int durationMilliseconds = 30000;
tt.IsBalloon = true;
tt.InitialDelay = 0;
tt.Show("tooltip text", pictureBox3, durationMilliseconds);
}要防止永久设置工具提示,请将事件处理程序添加到MouseEnter的picturebox中
private void pictureBox3_MouseEnter(object sender, EventArgs e)
{
tt.RemoveAll();
}https://stackoverflow.com/questions/44279982
复制相似问题