title: Remove/Unsubscribe Derived Class Load event from Base Class
body: <p>I have a base class that checks if user has access to the derived form. I need to block/remove invoke/unsubscribe to all methods/events in derived class from base class, if user doesn't have access to the form.</p>
  <p>I tried many things but couldn't find a way to handle this issue.</p>
  <p>My approach is close form in base form load event, but if data loading in derived form Load Event, it also raises and closes after data load. This can be leak of some security problems.</p>
  <p>I can easly solve this issue by adding some codes to derived form but i have about 450~500 about derived forms.</p>
  <p>Or i can define a function to show form, that checks user role in form before showing but because of many derived forms, i can't change.</p>
  <pre><code>Public Class AuthBaseForm
      Inherits DevExpress.XtraEditors.XtraForm
  
      Property IsAuthorized As Boolean = False
  
      Private Sub InitializeComponent()
  
          Me.SuspendLayout()
          '
          'StartUpForm
          '
          Me.ClientSize = New System.Drawing.Size(825, 432)
          Me.Name = &quot;AuthBaseForm&quot;
          Me.AutoScaleMode = Windows.Forms.AutoScaleMode.Dpi
          Me.ResumeLayout(False)
  
      End Sub
  
      Public Sub New()
          MyBase.New()
  
          ' Here checks if user can access and visible this form
          ' function return true/false
          IsAuthorized = GetUserRoleInForm(Me)
      End Sub
  
      Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
          If Not IsAuthorized Then
              'Remove Here Derived Class Load Event
              'Here, i need to find Derived class load event, and disable to invoke that method
  
  
              MsgBox(&quot;You do not have permissions to show this form!&quot;, vbExclamation + vbOKOnly)
              Me.Close()
              Return
          End If
      End Sub
  End Class
  
  Public Class DetailForm
      Inherits AuthBaseForm
  
      Public Sub New()
  
          ' This call is required by the designer.
          InitializeComponent()
  
      End Sub
  
      Private Sub DetailForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          ' this generated to test form role auth
          MsgBox(&quot;If also my base class not authorized, this event is raising :(&quot;, vbInformation)
  
          Me.KeyPreview = True
  
          ' Fetch data to show
          Me.WaitHelper1.SetListingFunction(Sub() Me.GetData())
  
          ' Set auto filter rows
          rh.devexFunc.SetGridViewFilterTypes(Me.viewSiparisler)
  
          ' Set column bolds
          rh.devexFunc.SetGridViewFontBold(Me.viewSiparisler, &quot;UNVAN&quot;)
      End Sub
  End Class
  </code></pre>
  <p>I've tried some works but still haven't get succeed.</p>