Mouse events in CF controls (ListView, TreeView, etc...)

B

batvanio

Hi,

I was exploring the possibility to implement dragging items in a
TreeView (or a ListView) control, for which I was planning to use the
MouseDown, MouseUp, etc... events. However, these are not implemented
for these controls (they are implemented only for Form, Panel,
Control, from my understanding). I tried to implement custom controls
derived from these, and override OnMouseUp, or just add the event and
the event handler in the custom control (since all these are derived
from Control), but it still does not seem to work. I also tried to
implement a custom WndProc, but this does not work either. I searched
the group, but did not find any solution not including third-party
controls.
Does anyone have any suggestion? This seems to be a pretty common
problem....

Thanks
Ivan
 
S

Simon Hart [MVP]

I never use the listview, grid control etc as I write my own but if the
listview doesn't support OnMouseDown etc you could try handle Click event
then "hack" the solution you need by detecting when the stylus was released
and position etc.
 
E

Ed Eaglehouse

The ListView, ListBox, etc. controls in the Compact Framework are very basic. They handle the mouse events internally and don't expose them. If you want a "click" event, you can use the SelectedIndexChanged event instead. If you want a double click, use the same handled and save the time between clicks to determine if it is a double click or not.

To get more useful or creative functionality, you have to write your own control and inherit from something like the Control or UserControl classes.

There is a more-or-less functional example in a .Net Framework Developer's Guide article, <a href="http://msdn.microsoft.com/en-us/library/ms229679.aspx" alt="How to: Create an Owner-Drawn List Box">How to: Create an Owner-Drawn List Box</a>, but it doesn't handle dynamic content. Good for basics, though.

You can examine a really tricked-out listbox control in the CodeProject article, <a href="http://www.codeproject.com/KB/list/SmoothListBox.aspx" alt="Implementing a smoothly animated ListBox">Implementing a smoothly animated ListBox - CodeProject</a>. This may be overkill for most purposes, but it does show you how intricate you can get.



batvani wrote:

Mouse events in CF controls (ListView, TreeView, etc...)
17-Jul-08

Hi

I was exploring the possibility to implement dragging items in
TreeView (or a ListView) control, for which I was planning to use th
MouseDown, MouseUp, etc... events. However, these are not implemente
for these controls (they are implemented only for Form, Panel
Control, from my understanding). I tried to implement custom control
derived from these, and override OnMouseUp, or just add the event an
the event handler in the custom control (since all these are derive
from Control), but it still does not seem to work. I also tried t
implement a custom WndProc, but this does not work either. I searche
the group, but did not find any solution not including third-part
controls
Does anyone have any suggestion? This seems to be a pretty commo
problem...

Thank
Ivan

Previous Posts In This Thread:

Mouse events in CF controls (ListView, TreeView, etc...)
Hi

I was exploring the possibility to implement dragging items in
TreeView (or a ListView) control, for which I was planning to use th
MouseDown, MouseUp, etc... events. However, these are not implemente
for these controls (they are implemented only for Form, Panel
Control, from my understanding). I tried to implement custom control
derived from these, and override OnMouseUp, or just add the event an
the event handler in the custom control (since all these are derive
from Control), but it still does not seem to work. I also tried t
implement a custom WndProc, but this does not work either. I searche
the group, but did not find any solution not including third-part
controls
Does anyone have any suggestion? This seems to be a pretty commo
problem...

Thank
Ivan

I never use the listview, grid control etc as I write my own but if the
I never use the listview, grid control etc as I write my own but if the
listview doesn't support OnMouseDown etc you could try handle Click event
then "hack" the solution you need by detecting when the stylus was released
and position etc
--
Simon Har
Visual Developer - Device Application Development MV
http://simonrhart.blogspot.co

:


Submitted via EggHeadCafe - Software Developer Portal of Choice
..NET Compact Framework Missing DataTable .Copy()
http://www.eggheadcafe.com/tutorial...14-841b27bdddb2/net-compact-framework-mi.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top