473,394 Members | 1,852 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,394 software developers and data experts.

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 3999
Something like this might do:

Private Sub ListBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseMove
For index As Integer = 0 To Me.ListBox1.Items.Count - 1
Dim r As Rectangle = Me.ListBox1.GetItemRectangle(index)
If e.Y >= r.Y AndAlso e.Y <= r.Y + r.Height Then
Me.Label1.Text = CStr(Me.ListBox1.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**@cbsmemphis.com> wrote in message
news:a1**************************@posting.google.c om...
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
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...
0
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...
3
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...
2
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...
5
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...
0
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...
1
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...
5
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.