473,789 Members | 2,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Draw a line between 2 list boxes using drag and drop...

Im starting on a application that will map fields from an excel file
to fields of a sql table for a very small integration project. I have
enabled drag and drop on the source listbox, and the form inbetween
the 2 listboxes so i can tell when im dragging over the form. Im stuck
on when i dragenter into the 2nd listbox, how can i figure out what
position their mouse is over, and what item is at that x and y
position? If anybody has any information on getting a listview item
and a clientpoint on the listbox, i would greatly appreciate it.

Thanks,
murl
Nov 20 '05 #1
2 4018
Something like this might do:

Private Sub ListBox1_MouseM ove(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListBox1.MouseM ove
For index As Integer = 0 To Me.ListBox1.Ite ms.Count - 1
Dim r As Rectangle = Me.ListBox1.Get ItemRectangle(i ndex)
If e.Y >= r.Y AndAlso e.Y <= r.Y + r.Height Then
Me.Label1.Text = CStr(Me.ListBox 1.Items(index))
Exit Sub
End If
Next

Me.Label1.Text = "none"

End Sub

This code only looks at the Y value, so it would not work if you had
multiple columns, but you could easily modify it for that. Obviously, I am
just displaying the value in a label, while you would be storing/using the
value in your code, but it should give a decent example of the method to
use. Also, the DragEventArgs will give you X and Y just like
MouseEventArgs.

You mentioned something about a ListViewItem in your post. If you use a
ListView rather than a ListBox, then you can use the GetItemAt method of the
ListView, passing a Point object.
Brian Davis
www.knowdotnet.com

"murl" <mu**@cbsmemphi s.com> wrote in message
news:a1******** *************** ***@posting.goo gle.com...
Im starting on a application that will map fields from an excel file
to fields of a sql table for a very small integration project. I have
enabled drag and drop on the source listbox, and the form inbetween
the 2 listboxes so i can tell when im dragging over the form. Im stuck
on when i dragenter into the 2nd listbox, how can i figure out what
position their mouse is over, and what item is at that x and y
position? If anybody has any information on getting a listview item
and a clientpoint on the listbox, i would greatly appreciate it.

Thanks,
murl

Nov 20 '05 #2
Ah,ok i noticed the get item at method but even think to loop through
the list of items to get it's index. I really apreciate it, that helped
me out alot, btw have you come accross any tutorials or code examples of
the steps for drawing the line from each listbox as in a field mapping
program, with redraw, etc?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3

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

Similar topics

0
2700
by: Tony Burger | last post by:
I'm trying to drag and drop files from a file list box to a directory list box (the two controls are not related). Does anyone have an examples of this? I've got the properties setup correctly on the two controls and I'm starting the OLEDrag method of the file list box using the mouse down event. This calls the OLEStartDrag where I am attempting to get the Data control object setup. I think this is where my problem may be. The OLEDragDrop...
0
1105
by: Dwayne Gaddy | last post by:
Hey all, I have a windows form with a list boxes. I have data bound the list boxes with data from my sql database. I want to use drag and drop to allow users to choose different options from the list boxes on the form and drag them into another empty list box that is not bound to any data when the form loads. I was wondering is it possible to use drag and drop with data bound list boxes ? If it is possible do you know of any place on...
3
1924
by: simon_s_li | last post by:
Hi, I am having problems using drag drop and re-ordering items. Example: When I drag and item from position 1 and drag it to position 3, I want to re-order all the items accordingly. This means an item in position 1 is now is position 3 and item 2 is now in postion 1 and item 3 is in position 2 and position 4 and 5 stay the same. I have searched the web.
2
4337
by: SamSpade | last post by:
There seems to be two ways to put things on the clipboard ( I don't mean different formats): SetClipboardData and OleSetClipboard If I want to get data off the clipboard do I care how it was put there? What about Drag/Drop; is there more than one way for the source to make data available Is it always OLE?
5
10166
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files dropped onto it.. does anyone have any examples of this? thanks
0
1069
by: Carl Gilbert | last post by:
Hi I am trying to draw a pie like shape on a form in the paint event. I am then trying to draw a line running down the center of the pie. The code I have attached at the bottom of this post does just this but there is something wrong somewhere as when I resize the form, the line does not stay over the center of the pie as expected. I should imagine its just a case of something round the wrong way but I just can't find what could be...
1
1756
by: Alan T | last post by:
I have a tree view on the left and a list view on the right. I will drag and drop from list view to treeview, and also drag drop tree node on the same tree view. How do I differentiate I drag from listview or within the tree view when I drop on the tree view ?
5
2075
by: =?Utf-8?B?UGFycm90?= | last post by:
Is there a way to perform a drag drop from a list box to a Gridview control on a web page? I can do it in a Windows form but I can't figure out how to do it on a web page. Dave
2
3040
by: hollinshead | last post by:
hi there, i have been having this issue for quite some time now and i cant seem to get my head around it. I am trying to create a database for candidates CV's and covering letters. basically the data that is stored is made up of qualifications and areas of business that candidate is involved etc. My problem is with the query by form where i have a range of combo boxes and list boxes. The combo boxes are working fine, no problem however the...
0
9511
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
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
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
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
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 project—planning, coding, testing, and deployment—without 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...
0
6765
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
5415
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...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
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

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.