?
Solved

Responding to a listBox double-click

Posted on 2004-11-21
5
Medium Priority
?
217 Views
Last Modified: 2010-04-15
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.

0
Comment
Question by:ba272
3 Comments
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 2000 total points
ID: 12640596
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
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12641222
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
 

Author Comment

by:ba272
ID: 12641246
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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question