473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DoubleClick a listview Item

Hi all
I have a listview with checkboxes and I would like to catch the doubleclick event on an Item.
Everything is o.k, BUT, the double clicking on the item, also checks/unchecks the checkbox of the item, which I don't want.

Can I work around this ?

Thanks In advance.
Jan 29 '09 #1
1 3342
vekipeki
229 Expert 100+
You can create a derived class and override WndProc to bypass the WM_LBUTTONDBLCLK message:

Expand|Select|Wrap|Line Numbers
  1. public class MyListView : ListView
  2. {
  3.     const int WM_LBUTTONDBLCLK = 0x203;
  4.     protected override void WndProc(ref Message m)
  5.     {
  6.         if (m.Msg == WM_LBUTTONDBLCLK)
  7.         {
  8.             // raise the event
  9.             this.OnDoubleClick(EventArgs.Empty);
  10.  
  11.             // but don't pass the message to base class
  12.             return;
  13.         }
  14.  
  15.         base.WndProc(ref m);
  16.     }
  17. }
Then open your Form.Designer.cs file and replace System.Windows.Forms.ListView with MyListView.

There are also some custom open-source controls like ObjectListView, some of which are a bit friendlier to use than ListView, and you have the source to customize it further to your needs.
Jan 30 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
2
by: Anushya devi | last post by:
Hi All I used listview and tried to update it by using Addrange. When the number of items is less, it works fine.. But I need to update nearly 200,000 items and it hangs. Also i need to add...
4
by: Bright Sun | last post by:
Hi, I have a ListView that is shown in Details mode, and the Checkboxes property is set to true. My problem is that I dont want the checkboxes being activated when items in the ListView are...
1
by: cody | last post by:
How can I prevent column autosizing on doubleclick on columnheader in a ListView? -- cody Freeware Tools, Games and Humour http://www.deutronium.de.vu || http://www.deutronium.tk
9
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to...
3
by: active | last post by:
DoubleClick seems to work OK with a ListBox. However, with a ListView I never get the event fired. I looked at both the LIstBox and ListView events and neither lists the DoubleClick??? But...
2
by: active | last post by:
I'm about ready to give up unless someone has an idea. Trying to do in a ListView DragDrop and DoubleClick. I can make it work if they use different mouse buttons. But if I use the left...
0
by: Mark | last post by:
Hello, I want to do different actions when clicking then when doubleclicking on an item in the listview. With doubleclicking, clicking events is also fired. How can I avoid doing the 2? Use...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.