Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I recently read (An Outlook Bar Implementation[^]) and now attempting to implement OutlookBar in vb.net project, however, having some difficulty w/ some of the code.

I am trying to determine how the events that are invoked in the OutlookBar class are translated to vb.net. For example, when the click event for the label is invoked in the AddIcon routine:
label.Click+=onClickEvent;


I have tried raising an event but the compiler indicates that derived classes can not raise base events.

Should I call PerformClick()?

Help is appreciated.
Posted
Updated 23-Mar-12 14:21pm
v3

As given here
http://msdn.microsoft.com/en-us/library/0ecakwbz.aspx[^]
An event can be raised only from the declaration space in which it is declared. Therefore, a class cannot raise events from any other class, even one from which it is derived.

May be you are trying to raise an event from other class.
But as for as the OutlookBar AddIcon routine is concerned, it assigns the instance of a EventHandler delegate which is passed as parameter to the Click event of the label. You need not raise the event. When the label is clicked the Click event of the label is raised by the label control and the instance of EventHandler supplied in the AddIcon routine is invoked.
So, don't raise the event yourself, only supply an instance of the EventHandler delegate as a parameter as already given in the demo application given the referred article.
 
Share this answer
 
Comments
wrappingduke 24-Mar-12 13:50pm    
Thank you for your reply. It's appreciated. My apologies if my inquiry was vague. What I trying to find out is how to duplicate the same event calls in the OutlookBar class but in vb.net? For example, in the PanelIcon constructor OutlookBar, the following code appears in C#:

Click+=onClickEvent;
Tag=this;

MouseEnter+=new EventHandler(OnMouseEnter);
MouseLeave+=new EventHandler(OnMouseLeave);
MouseMove+=new MouseEventHandler(OnMouseMove);
ProEnggSoft 24-Mar-12 20:17pm    
Sorry I could not under stand from your question. Now I understood what is required exactly. Please see my Solution (4).
This is not a solution. Thank you for your reply. It's appreciated. My apologies if my inquiry was vague. What I trying to find out is how to duplicate the same event calls in the OutlookBar class but in vb.net? For example, in the PanelIcon constructor OutlookBar, the following code appears in C#:
C#
Click+=onClickEvent;
Tag=this;
MouseEnter+=new EventHandler(OnMouseEnter);
MouseLeave+=new EventHandler(OnMouseLeave);
MouseMove+=new MouseEventHandler(OnMouseMove);



Help is appreciated
 
Share this answer
 
The equivalent of
C#
Click+=onClickEvent;
Tag=this;
MouseEnter+=new EventHandler(OnMouseEnter);
MouseLeave+=new EventHandler(OnMouseLeave);
MouseMove+=new MouseEventHandler(OnMouseMove);

in VB.NET is
VB
AddHandler Click, AddressOf onClickEvent
Tag=Me
AddHandler MouseEnter, New EventHandler(AddressOf OnMouseEnter)
AddHandler MouseLeave, New EventHandler(AddressOf OnMouseLeave)
AddHandler MouseMove, New MouseEventHandler(AddressOf OnMouseMove)

AddHandler MouseEnter, AddressOf OnMouseEnter
'is a shortcut to 
AddHandler MouseEnter, New EventHandler(AddressOf OnMouseEnter)


'Hence, it is valid to use 
AddHandler MouseEnter, AddressOf OnMouseEnter
'instead of 
AddHandler MouseEnter, New EventHandler(AddressOf OnMouseEnter)
 
Share this answer
 
Comments
wrappingduke 26-Mar-12 22:35pm    
That did it. Thank you for your help. It's appreciated!
ProEnggSoft 26-Mar-12 22:38pm    
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900