【发布时间】:2015-06-11 14:24:03
【问题描述】:
我有一个带有列表视图的 vb 应用程序。 我正在测试并最终为我的拖动事件使用了这个子:
Private Sub ListView1_DragOver(sender As Object, e As DragEventArgs) Handles ListView1.DragOver
XToolStripLabel.Text = "X:" & e.X
YToolStripLabel.Text = "Y:" & e.Y
Dim Insertion As Integer = GetInsertion(MousePosition, ListView1)
SelectionTestTSlabel.Text = "SEL " & Insertion
If CurrentlyDragging Then
Dim gr As Graphics = ListView1.CreateGraphics
Windows.Media.VisualTreeHelper.GetChild(New Windows.DependencyObject(), 0) 'I know this seems like it doesn't do much
MsgBox("") 'I actually added this later because the rest of the code did not run normally.
Dim InsertionY As Integer = 24 + (Insertion * TestItemHeight)
If MyLastInsPoint = Insertion Then
Else
ListView1.Refresh()
gr.DrawLine(New Pen(Color.Gray, 3), New Point(0, InsertionY), New Point(ListView1.Width, InsertionY))
End If
MyLastInsPoint = Insertion
End If
End Sub
我意识到 MsgBox("") 没有弹出消息框,然后我在整个 sub 上发送断点垃圾邮件。
子程序正常运行,但在此行之后,
Windows.Media.VisualTreeHelper.GetChild(New Windows.DependencyObject(), 0)
程序返回窗体,没有执行 MsgBox("") 行。
线路有什么问题?程序甚至没有在 End Sub 断点处停止。
【问题讨论】: