如何:将鼠标悬停在形状上显示文本框

How To: Hover Over Shape Shows TextBox

我正在努力做到这一点,当用户将鼠标悬停在如下所示的三角形上时,会弹出一个文本框,其中包含与该三角形相关的某些信息。

使用以下函数绘制三角形...

Public Sub drawTriangle(theRow As Integer, theColumn As Integer, Optional myColor As System.Drawing.Color = Nothing)
        myColor = System.Drawing.Color.Black
        Dim theShape As Microsoft.Office.Interop.Excel.Shape = xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle, (xlWorkSheet.Cells(theRow, theColumn)).Left + 18, (xlWorkSheet.Cells(theRow, theColumn)).Top, 15, 14)
        theShape.Fill.ForeColor.RGB = ToBgr(myColor)
        theShape.Line.ForeColor.RGB = ToBgr(myColor)

    End Sub

我找不到任何关于如何执行此操作的示例或良好的文档,所以我想我应该在这里问一下。非常感谢任何帮助!!

根据MSDN,注释可以添加到范围。为了使它适用于您的应用程序,您只需 select 对应于您的形状的范围,然后调用 AddComment()。

单元格的数字坐标可用于确定实际的单元格名称(即 E5),方法如下(source):

address = xlWorkSheet.Cells(RowVariable, ColVariable).Address

这可以跟进:

xlWorkSheet.Range(address).AddComment("This is a comment")