很抱歉,这似乎是一个愚蠢的问题或编码不正确。我对OOP和Visual Studio 2017环境非常陌生
并在陡峭的学习曲线上努力。我正在尝试编写一些代码来处理树视图的拖放操作。
以下是相关代码段:
Private Sub TreeView2_DragOver(sender As Object, e As DragEventArgs) Handles TreeView2.DragOver
If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", True) = False Then Exit Sub
Dim selectedTreeview As TreeView = CType(sender, TreeView)
Dim pt As Point
pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y)) '<- This Line Generates Error
Dim targetNode As TreeNode = selectedTreeView.GetNodeAt(pt)
strong textEnd Sub
问题在于Point被定义为我无法正确实现的接口(并非缺乏尝试)。 评估PointToClient时发生我收到的错误:类型'Point'的值无法转换为'Point'。 到目前为止,这是我对界面所做的:
Interface IPoint
Sub Point(x As Integer, y As Integer)
End Interface
Class Point
'Inherits System.Drawing.Point '<- Generated an error
Implements IPoint
Public Sub IPoint_Point(X As Integer, Y As Integer) Implements IPoint.Point
Throw New NotImplementedException()
End Sub
Public X, Y As Integer
Public Sub New(newX As Integer, newY As Integer)
X = newX
Y = newY
End Sub
End Class
我试图继承System.Drawing.Point以获取必要的功能。但是,这产生了一个错误,提示“ 类只能 从其他类继承”。有没有解决的办法?我的方法有意义吗?
我在Visual Studio 2017中的项目类型是Excel 2013和2016 VSTO WorkBook。
任何指导方针和/或建议,我们将不胜感激。 谢谢!