EventHandler assignment

A

Alan T

private void MainForm_Load(object sender, EventArgs e)

{

tsHelpDropDownButton.MouseLeave += new
EventHandler(this.MenuDropDownButton_MouseLeave);

}

private void MenuDropDownButton_MouseLeave(object sender, EventArgs e)

{

(ToolStripDropDownButton)sender.HideDropDown(); // ERROR

}

I got a compilation error:

"Only assignment, call, increment, decrement, and new object expressions can
be used as a statement"

What did I do incorrectly?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You are missing a set of () :

( (ToolStripDropDownButton)sender ) .HideDropDown();
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top