Hi,
I have a ControlBase object which I am inheriting all of my user controls from and I have overriden a method in the extended user control. This overriden method runs fine most of the time, but every now and again, the application does not run the overriden procedure. It continues excecution as though the method was never overriden.![]()
Here is an example
VB Code:
Public Class ControlBase Inherits System.Windows.Forms.UserControl #Region " Windows Form Designer generated code " Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click OnBeforeSave() OnSave() OnAfterSave() End Sub Protected Overridable Sub OnSave() ' End Sub Protected Overridable Sub OnBeforeSave() ' End Sub Protected Overridable Sub OnAfterSave() ' End Sub End Class Public Class ExtendedControl Inherits WindowsApplication3.ControlBase #Region " Windows Form Designer generated code " Protected Overrides Sub OnAfterSave() MyBase.OnAfterSave() MsgBox("hello world from onaftersave") End Sub Protected Overrides Sub OnBeforeSave() MyBase.OnBeforeSave() MsgBox("hello world from onbeforesave") End Sub Protected Overrides Sub OnSave() MyBase.OnSave() MsgBox("hello world from onsave") End Sub End Class
The excecution path looks like this:
ControlBase -> btnSave_Click
ExtendedControl -> OnBeforeSave
ControlBase -> OnBeforeSave
ControlBase -> OnSave
ExtendedControl -> OnAfterSave
ControlBase -> OnAfterSave
I thought I had done something wrong, but it sometimes runs the overriden code and sometimes not. Has anyone else had this problem or am I just smoking something?
Win2ksp3
.NET 2003
Framework V1.1.4322




Reply With Quote