Click here to Skip to main content
15,031,219 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Cannot implicitly convert type 'bool' to 'System.EventHandler'
Posted
Comments
Maciej Los 13-May-12 5:43am
   
...so what?
And a code is...
Hesha 13-May-12 5:46am
   
Please provide some sort of Code or a Explanation about your matter.otherwise it is hard to provide solution for your matter.
bbirajdar 13-May-12 11:31am
   
Ok..
Bilawal Alee 13-May-12 11:37am
   
i want that when button is click the checkbox enabled

1 solution

The error message stated in the title of the question is displayed if a boolean value is assigned instead of an Event handler. For example, the Click event of a Button can be handled by assigning the Event handler button1_Click as explainere here
http://msdn.microsoft.com/en-us/library/dfty2w4e(v=vs.80).aspx[^]
C#
button1.Click += new EventHandler(button1_Click);

where button1_Click is declared as below
C#
private void button1_Click(object sender, System.EventArgs e)
{
// Add event handler code here.
}

In the above code if a boolean value is assigned like
C#
button1.Click += variableOfBoolValue;

where variableOfBoolValue is a variable containing a boolean value, then the above error is thrown. To avoid that error assign a Event handler of appropriate type corresponding to the event which is to be handled.

I think this is what can be inferred with the minimum info provided in the question.
   
v2
Comments
Maciej Los 13-May-12 6:22am
   
Great! +5
VJ Reddy 13-May-12 6:53am
   
Thank you, losmac.

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