Using Delegates in vb.net cf

  • Thread starter Thread starter dwhittenburg
  • Start date Start date
D

dwhittenburg

I have used delegates in c#, but I'm trying to get this working with vb.net

I have an object called Panel that contains a button...when the button is
clicked I want it to call a function of all methods subscribed to be
called...

I have a container class that contains this Panel object and I want it to
be notified when the button is clicked...

Could anyone show me how to use delegates in vb.net?

Thanks
 
Amazingly, delegates syntax is covered in the VB language reference shipped
with Visual Studio MSDN.

In VB you can either use WithEvents descriptor on the variable declaration
(class members) and Studio will show such variables in a left dropdown,
while the right one will let you to create a handler automatically, or you
can use explicit syntax:

AddHandler panel.Clicked, AddressOf MyClickedEventHandler

See the MSDN index for AddHandler statement
 
I used RaiseEvent...


Alex Feinman said:
Amazingly, delegates syntax is covered in the VB language reference
shipped with Visual Studio MSDN.

In VB you can either use WithEvents descriptor on the variable declaration
(class members) and Studio will show such variables in a left dropdown,
while the right one will let you to create a handler automatically, or you
can use explicit syntax:

AddHandler panel.Clicked, AddressOf MyClickedEventHandler

See the MSDN index for AddHandler statement
 
Yes, RaiseEvent works for raising events. Handling the event on the client
side can be done with either of the two approaches Alex described:
AddHandler or WithEvents/Handles

Cheers
Daniel
 
Back
Top