Responding to a listBox double-click

I assume I'm just overlooking something obvious.  I'd like to override the event which fires as a result of the user double-clicking on an item in a listbox.

Thanks for the help.

ba272Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mohammed NasmanSoftware DeveloperCommented:
Hello

  Here's a simple example to create new ListBox control named MyListBox, and I override the doubleclick event so it show messagebox each time you double click on it,

then add it to Toolbox, and it will be new control with your new implementation of DoublClick

using System;
      public class MyListBox:System.Windows.Forms.ListBox
      {
            protected override void OnDoubleClick(System.EventArgs e)  
            {
                  // add your code here
                  System.Windows.Forms.MessageBox.Show("My Double click");
            }                  
      }

HTH

Regards,
Mohammed
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chester_M_RagelCommented:
As mnasman said, If you want to override a methord in a class which is virtual, then you must drive a class from that and override that method. The purpose of this is in this concept is that, if you are going to develop a custom control or something you can do that. There are lot of examples on the web for custom listbox controls. If you weant more information, let me know.

Chester.
0
ba272Author Commented:
Thanks Chester,

But it turns out the first event listed in the Action section of the events window (associated with the Properties window) is DoubleClick.  All I needed to do was double click it and it generated the event for me.  But I like his approach and may try it with other things as well.

Thanks for asking.

Bob
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.