Menuitem clicked repeating multiple time

Dec 30 2018 11:56 PM
I am new to C# I manually populate a context menu with a item click event populated from a listbox of video files located on my drive. The click events fires as expected but repeats 4 times? I only want it to go to the click event once.
 
Populate menu using listbox code. When a menu item is in mouse hover it creates and populate a menu with a item click event as shown below. The issue is once I click a menu item it goes back to the item click event 4 times on a single click.Being as I am converting mp4 to mp3 files it is very time consuming is there a way I can stop it from running the click event multiple time I tried using a bool statement I even tried making the click event wait using async void. Any help would be appreciated. Thanks in advance.
  1. private void CsConvertMP4ToMP3_Hover(object sender, EventArgs e)  
  2.        {  
  3.   
  4.            CSselectVideoFile.DropDownItems.Clear();  
  5.   
  6.            foreach (String Item in lstVideoFiles.Items)  
  7.            {  
  8.                CSselectVideoFile.DropDownItems.Add(Item);  
  9.                foreach (ToolStripItem mnuitem in CSselectVideoFile.DropDownItems)  
  10.                {  
  11.                    //Add click event hander for each new menuitem added  
  12.                    mnuitem.Click += new EventHandler(item_Click);  
  13.                }  
  14.            }   
  15.        }  
  16.   
  17.        void item_Click(object sender, EventArgs e)  
  18.        {  
  19.            ToolStripItem clickedItem = sender as ToolStripItem;  
  20.            ConvertVideoToMP3(MP4Name);  
  21.        }  

Answers (3)