Reputation: 1625
Facing an issue while accessing declared event in vb.net.
Please go thorough below example. (I have modified below stuff to make understable as it is part of one of custom control development)
Public Class Main
Inherits ComboBox
'Event handler for when an item check state changes.
Public Event ItemCheck As ItemCheckEventHandler
Private parentMainClass As Main
Private cclb As controlClass
Public Sub New(parentclass As Main)
Me.parentMainClass = parentclass
'Add a handler to notify our parent of ItemCheck events.
AddHandler Me.cclb.ItemCheck, New System.Windows.Forms.ItemCheckEventHandler(AddressOf Me.cclb_ItemCheck)
End Sub
Private Sub cclb_ItemCheck(sender As Object, e As ItemCheckEventArgs)
'If ccbParent.ItemCheck IsNot Nothing Then
RaiseEvent parentMainClass.ItemCheck(sender,e)
'End If
End Sub
Public Class controlClass
Inherits CheckedListBox
End Class
End Class
Problem: RaiseEvent parentMainClass.ItemCheck(sender,e)
this statement shows - ItemCheck event not exists even though it is existed.
Please guide.
Thank You
Upvotes: 0
Views: 346
Reputation: 672
From your original code, the line;
RaiseEvent parentMainClass.ItemCheck(sender, e)
should be changed to;
RaiseEvent ItemCheck(sender, e)
This raises the ItemCheck event from the current instance. What you seem to be wanting to do is to raise the event on the parent instance, which is a bit different.
Upvotes: 0
Reputation: 672
The event declaration;
Public Event ItemCheck As ItemCheckEventHandler
Should be;
Public Event ItemCheck(sender As Object, e As ItemCheckEventArgs)
What the error is telling you is that it cannot match up the event to the event handler signature.
Upvotes: 1