当我调试某个应用程序时,我会执行一个ctrl-Break,然后单步执行以查看代码的去向,并且有时候会触发该事件(通常是所有绘制事件)。所以我想知道是否可以在vb事件子中自行禁用/删除事件处理程序在运行时:
Protected Overrides Sub OnPaintBackground(ByVal e As System.Windows.Forms.PaintEventArgs)
statement that I can add to disable that event manager
...
code I don't want to be executed temporarily
....
End Sub
答案 0 :(得分:1)
您可以有条件地编译代码,具体取决于您的构建类型。例如,如果您正在进行调试构建,则可以更改代码。
Public Class Form1
Private Sub Form1_Load(....)
#if DEBUG then
<do something>
#else
<do something else>
#end if
End Sub
End Class