TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dwainsnickles
NA
712
0
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.
private
void
CsConvertMP4ToMP3_Hover(
object
sender, EventArgs e)
{
CSselectVideoFile.DropDownItems.Clear();
foreach
(String Item
in
lstVideoFiles.Items)
{
CSselectVideoFile.DropDownItems.Add(Item);
foreach
(ToolStripItem mnuitem
in
CSselectVideoFile.DropDownItems)
{
//Add click event hander for each new menuitem added
mnuitem.Click +=
new
EventHandler(item_Click);
}
}
}
void
item_Click(
object
sender, EventArgs e)
{
ToolStripItem clickedItem = sender
as
ToolStripItem;
ConvertVideoToMP3(MP4Name);
}
Reply
Answers (
3
)
Is there any way to print a wpf/c# form without print dialo?
I have attach 2 tables record in one windows form and save