Click here to Skip to main content
14,983,551 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
In my form I have a Button Control(Button1),Contextmenustrip1.

when i click on button1 a new label control will be created dynamically(LblDynamic).

When i click on LblDynamic LeftmoustButton i need to show this Contextmenustrip1.

For that i wrote,

LblDynamic.MouseClick += new EventHandler(OnLeftClick);

void OnLeftClick(object sender, MouseEventArgs e)
{


}

But, It gives me an error
No Overload for 'OnLeftClick' matches delegate 'System.EventHandler'

Any idea plz let me know..

Thanks in advance.
Posted

declare event as public or protected.

for example.
C#
public void OnLeftClick(object sender, MouseEventArgs e)
{

}
   
v2
Hi,

I used <pre lang="xml">&lt;pre lang=&quot;midl&quot;&gt;LblDynamic.MouseClick += new MouseEventHandler(OnLeftClick);&lt;/pre&gt;</pre>.


It works fine.
   

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