473,703 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mouse position on the Listview by Drag&Drop?

Sim

Hello NG,

I try to use drag and drop function between two list views. For this I found
following code:

http://msdn.microsoft.com/library/de...mpdragdrop.asp

It works fine, but I have another problem. I want to create functionality
like a Windows Explorer. This means, if I select some items from list view No
1 and drag&drop this to the list view No 2, then I want to mark automatically
the item from list view No 2 under the mouse cursor (this would be like same
as if you want to copy some files to a directory in Windows Explorer. The
actually directory under mouse will be marked).

For check this event I use following function:

Private Sub ListView_DragOv er(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles MyListView.Drag Over




End Sub

And for get the actually item index, I use this method:
Me. MyListView.GetI temAt(e.X, e.Y).Index
So I can mark the Item under my cursor by drag&drop.
It would be good, but the event arguments e.X and e.Y returns the global
mouse position!!! So I cannot use this, because I need the relative cursor
position to the list view!

How can I get the actually list view mouse position used Drag.Over event?

Thanks
simon

Oct 26 '06 #1
1 5373
Sim
Solution:

' Highlight the item under the mouse.
Private Sub List_DragOver(B yVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles LV_Dir.DragOver
Dim this_list As ListView = DirectCast(send er, ListView)
Dim pt As Point = this_list.Point ToClient(New Point(e.X, e.Y))
Dim drop_index As Integer = this_list.GetIt emAt(pt.X, pt.Y).Index

this_list.Selec tedItems.Clear( )
this_list.Items (drop_index).Se lected = True
If pt.Y < 5 Then this_list.Ensur eVisible(drop_i ndex - 1)
If pt.Y this_list.Heigh t - 10 Then
this_list.Ensur eVisible(drop_i ndex + 1)
End Sub
"Sim" wrote:
>
Hello NG,

I try to use drag and drop function between two list views. For this I found
following code:

http://msdn.microsoft.com/library/de...mpdragdrop.asp

It works fine, but I have another problem. I want to create functionality
like a Windows Explorer. This means, if I select some items from list view No
1 and drag&drop this to the list view No 2, then I want to mark automatically
the item from list view No 2 under the mouse cursor (this would be like same
as if you want to copy some files to a directory in Windows Explorer. The
actually directory under mouse will be marked).

For check this event I use following function:

Private Sub ListView_DragOv er(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles MyListView.Drag Over




End Sub

And for get the actually item index, I use this method:
Me. MyListView.GetI temAt(e.X, e.Y).Index
So I can mark the Item under my cursor by drag&drop.
It would be good, but the event arguments e.X and e.Y returns the global
mouse position!!! So I cannot use this, because I need the relative cursor
position to the list view!

How can I get the actually list view mouse position used Drag.Over event?

Thanks
simon
Oct 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4165
by: srikanth | last post by:
Hi all, I have an requirement in one of my projects. We have one aspx page, in that we have two frames, in each frame having a tree structure control(dynamic data). In the left Frame we are displaying all the documentcollections(dynamic) in the Treestructure, In the Right side we are displaying all the HolderGroups (dynamic).We have to assing Any one of the Documentcollections to HolderGroups, through Drag and Drop
1
2429
by: Targa | last post by:
I have an ASP scheduling application in which there are blocks of time, represented with a table, within another table which is the timeline. In other words, I have a table with a vertical timeline. Each row represents a 1/2 hour of time starting at 12 AM. The scheduled job is represented by another smaller table inside the timeline table which spans vertically the time alloted for the job. Say if the job was scheduled for 2 hours, the...
1
7640
by: Karsten Schramm | last post by:
Hi, if I drag an Outlook.MailItem to a Windows-Explorer window a <subject>.msg file will be created. Now I try to drag & drop a mail item to my own WinForm app. Unfortunately it doesn't work. In the "drop event" are eight DataFormats (e.Data.GetFormats()) but the important one (imho) "FileContents" is "Nothing"/"null".
0
2271
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly delicately balanced and finding my way through it has descended into one of those awful situations which I refer to as guess & test. From the point at which DoDragDrop() function is called until some later
2
9199
by: Grey | last post by:
I need to design a workflow application with C#. I want to design an UI with some workflow components which they can be drag & drop anywhere in order to design the workflow for the application users. Moreover, when the user double click on the component, they can define some routing rules for the process. Is it possible to have such fancy UI in C#?? Any reference sites or tutorial?? Million Thanks.
5
4869
by: sesar | last post by:
How can I impement drag&drop for simple 'dialog base' application... I want to drag&drop txt file and load the text to variable
0
2520
by: haegens | last post by:
I am making a .NET Application which has a TreeView Control in it. I have 3 levels of nodes. The toplevel is a rootnode which contains all other nodes. The second level holds one kind of nodes that have one type of objects assigned to the tag property. The third level holds another kind of nodes. Also this level has one type of objects assigned to the tag property. The objects that are assigned in the third level nodes, are child objects of...
5
1541
by: murrayatuptowngallery | last post by:
I saw a 2-D (like a joystick) slider widget awhile ago. I thought it was on the dojotoolkit.org Demo page, but no one there acknowledges it (they don't deny it either). I would like to learn how to build one of these to allow two parameters to be adjusted simultaneously but independently with one action. I'm starting to wonder if it's really a drag & drop type application and not a slider. Calling it a slider seems to generate 'no,...
1
3828
by: patrickq | last post by:
What am trying to achieve is dragging an element from one IFRAME/FRAME into another IFRAME/FRAME. But upon dropping the element, I do not want the target IFRAME/FRAME to open/load it. I want to set the data type to "text" at the source, so that the drop operation simply drops a set text string onto a target text entry field. Under IE, when dragging an object, it is possible to catch the dataTransfer.setData event to set up the data to be...
0
8759
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8669
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9122
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4433
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3125
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2453
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.