why not work like in example ?

silvestri silvestri 1 Reputation point
2021-01-20T12:34:17.277+00:00

Hi guys i try to run this simple example but VS2019 with Net 4.8 return me this error https://learn.microsoft.com/it-it/dotnet/api/system.windows.forms.toolstripitemclickedeventargs.clickeditem?view=net-5.0# private void ToolStrip1_ItemClicked(Object sender, ToolStripItemClickedEventArgs e) { System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder(); messageBoxCS.AppendFormat("{0} = {1}", "ClickedItem", e.ClickedItem ); messageBoxCS.AppendLine(); MessageBox.Show(messageBoxCS.ToString(), "ItemClicked Event" ); } Severity Code Description Project File Line Suppression State Error CS1061 'EventArgs' does not contain a definition for 'ClickedItem' and no accessible extension method 'ClickedItem' accepting a first argument of type 'EventArgs' could be found (are you missing a using directive or an assembly reference?) ControllerH C:\Users\stefano\source\repos\ControllerH\ControllerH\Form1.cs 28 Active thanks at all

Developer technologies | C#
{count} votes

6 answers

Sort by: Most helpful
  1. Bonnie DeWitt 811 Reputation points
    2021-01-24T23:35:28.38+00:00

    @silvestri silvestri

    Change your code (in two places) to look like this:

    // 1) change this:  
    this.ninjaTraderToolStripMenuItem.Click += new System.EventHandler(this.ninjaTraderToolStripMenuItem_Click);  
      
    // to this:  
    this.ninjaTraderToolStrip.ItemClicked += new ToolStripItemClickedEventHandler(ninjaTraderToolStrip_ItemClicked);  
      
      
      
    // 2) change this:  
    private void ninjaTraderToolStripMenuItem_Click(object sender, EventArgs e)  
      
    // to this:  
    private void ninjaTraderToolStrip(object sender, ToolStripItemClickedEventArgs e)  
    

    ~~Bonnie DeWitt [MVP since 2003]
    http://geek-goddess-bonnie.blogspot.com

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.