2
A
回答
5
这是我的代码上设置一个复合控件工具提示,可能给你一个线索(LED derivers从用户控件):
public LED()
{
InitializeComponent();
m_Image = global::AdvAdmittance.Controls.Properties.Resources.ledgray_small;
m_ToolTip = new ToolTip();
m_ToolTip.AutoPopDelay = 5000;
m_ToolTip.InitialDelay = 1000;
m_ToolTip.ReshowDelay = 500;
m_ToolTip.ShowAlways = true;
m_LedPictureBox.MouseHover += new EventHandler(m_LedPictureBox_MouseHover);
m_LedPictureBox.MouseLeave += new EventHandler(m_LedPictureBox_MouseLeave);
m_LedPictureBox.Click += new EventHandler(m_LedPictureBox_Click);
}
void m_LedPictureBox_MouseHover(object sender, EventArgs e)
{
if (m_ToolTipText != string.Empty)
{
Point toolTipPoint = this.Parent.PointToClient(Cursor.Position);
toolTipPoint.Y -= 20;
m_ToolTip.Show(m_ToolTipText, this.Parent, toolTipPoint);
}
}
void m_LedPictureBox_MouseLeave(object sender, EventArgs e)
{
m_ToolTip.Hide(this.m_LedPictureBox);
}
1
2
啊,谢谢你的回答。
我需要的是一个PointToClient方法。
我希望(也许)它会对其他人有用,在这里是“我的”代码。
我把几乎所有的代码http://support.microsoft.com/kb/322634和修改三行:
void treeView1_MouseMove(object sender, MouseEventArgs e)
{
// Get the node at the current mouse pointer location.
TreeNode theNode = this.treeView1.GetNodeAt(e.X, e.Y);
// Set a ToolTip only if the mouse pointer is actually paused on a node.
if ((theNode != null))
{
// Verify that the tag property is not "null".
if (theNode.Tag != null)
{
// Change the ToolTip only if the pointer moved to a new node.
if (theNode.Tag.ToString() != this.toolTip1.GetToolTip(this.treeView1))
{
//this.toolTip1.SetToolTip(this.treeView1, theNode.Tag.ToString());
Point c = System.Windows.Forms.Cursor.Position;
Point p = treeView1.PointToClient(c);
this.toolTip1.Show(theNode.Tag.ToString(), treeView1, p);
}
}
else
{
this.toolTip1.SetToolTip(this.treeView1, "");
}
}
else // Pointer is not over a node so clear the ToolTip.
{
this.toolTip1.SetToolTip(this.treeView1, "");
}
}
相关问题
- 1. 如何获得坐标相对于鼠标位置的位置?
- 2. 找到图像的左上角位置
- 3. 如何设置里面的图片位置标签位于左上角而文字位于左下方
- 4. 得到鼠标的位置相对于父元素
- 5. 位置图左上角
- 6. C#相对于应用程序的光标位置
- 7. 获取游标相对于控件的位置 - C#
- 8. 相对于控件获取鼠标位置
- 9. 相对于div的鼠标位置?或div位置相对于查看窗口?
- 10. jQuery:如何获取鼠标相对于元素的顶部/左侧角落的位置考虑到滚动条
- 11. 获取控件右上角的位置
- 12. ggplot:左上角的位置传说
- 13. 与表格相关的光标位置
- 14. 相对于上一格的位置div
- 15. 控制在UITextField中的光标位置
- 16. 光标位置
- 17. 事件和光标位置
- 18. 当窗体位于主显示器的上方和左侧时,光标变为对角线调整大小
- 19. 如何获得控件相对于窗口客户端矩形的位置?
- 20. 我们怎样才能得到相对于窗体的位置?
- 21. 如何在WinForms相对位置设置子控件的位置?
- 22. 相对于类的Java文件位置
- 23. 如何获得光标位置
- 24. 相对布局的Android左下角与图像中心的位置相同
- 25. 跟踪光标位置可可并返回鼠标相对于窗口的位置
- 26. 得到桌子上的坐标位置
- 27. 获取JPopupMenu对象的左上角位置
- 28. FLEX:我如何设置组件的左下角坐标而不是左上角
- 29. 在textview上设置光标位置
- 30. 如何获取控件相对于其表单位置的位置?