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. 如何將光標位置貼在UITextView的左上角?
- 3. 如何獲得座標相對於鼠標位置的位置?
- 4. 將控件移動到光標位置?
- 5. 如何獲得相對和絕對光標位置?
- 6. 找到圖像的左上角位置
- 7. 花式框位置絕對左上角
- 8. Kinect v2相對光標位置
- 9. 對光標位置
- 10. 如何設置裏面的圖片位置標籤位於左上角而文字位於左下方
- 11. 得到鼠標的位置相對於父元素
- 12. 位置圖左上角
- 13. 相對左上角動態更改div位置
- 14. 獲取遊標相對於控件的位置 - C#
- 15. Javafx - 確定光標相對於柵格的右擊位置
- 16. C#相對於應用程序的光標位置
- 17. 如何設置光標位置輸入的左上邊緣
- 18. 將光標移動到控制檯的左下角
- 19. Css位置角落絕對左下角
- 20. C#自定義控件光標位置
- 21. 相對於控件獲取鼠標位置
- 22. F#,從相對於IInputElement的鼠標光標位置提取網格座標
- 23. proc報告文本位置左上角和左上角
- 24. 相對於div的鼠標位置?或div位置相對於查看窗口?
- 25. jQuery:如何獲取鼠標相對於元素的頂部/左側角落的位置考慮到滾動條
- 26. 如何使相對於鼠標位置的標籤位置
- 27. 相對於原點的鼠標位置
- 28. 獲取控件右上角的位置
- 29. 將窗口放置到WPF控件的左上角
- 30. jquery - 屏幕左上角的位置