473,418 Members | 2,064 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,418 software developers and data experts.

Drag and Drop within one list box

JL
I have found may examples for dragging and dropping between list boxes
but I need to do it within one. Can some one point me to a tutorial or
example. Prefer VB but can use C# too.

TIA,
John
Nov 23 '05 #1
3 4750
Hi,

I think that you'll find useful information about Drag & Drop in the next URL:
http://www.vb-helper.com/howto_net_d...op_object.html

I hope that helps.

Best regards,

--
Jorge Serrano Pérez
Microsoft MVP VB.NET
PortalVB.com
http://www.portalvb.com/
Weblog de Jorge Serrano
http://weblogs.golemproject.com/jorge/
"JL" wrote:
I have found may examples for dragging and dropping between list boxes
but I need to do it within one. Can some one point me to a tutorial or
example. Prefer VB but can use C# too.

TIA,
John

Nov 23 '05 #2
JL
Thank you Jorge for the response. I did find that article when I ran
Google. And I understand doing drag/drop between controls but not
within a single ListBox so my user can re-order the items in the list.

John

On Sun, 13 Nov 2005 04:36:04 -0800, "Jorge Serrano [MVP VB]"
<NO*******************@NOQUIEROSPAMportalvbNOSPAM. com.NOQUIEROSPAM>
wrote:
Hi,

I think that you'll find useful information about Drag & Drop in the next URL:
http://www.vb-helper.com/howto_net_d...op_object.html

I hope that helps.

Best regards,


Nov 23 '05 #3
Ok.

I hope that the next sample of code helps you to understand how can you use
the drag & drop feature in VB.NET. :-)
Regards.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add("ListBox1 - Ele 1")
ListBox1.Items.Add("ListBox1 - Ele 2")
ListBox1.Items.Add("ListBox1 - Ele 3")
ListBox1.Items.Add("ListBox1 - Ele 4")

ListBox2.Items.Add("ListBox2 - Ele 1")
ListBox2.Items.Add("ListBox2 - Ele 2")
ListBox2.Items.Add("ListBox2 - Ele 3")

ListBox2.AllowDrop = True
End Sub

Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If (ListBox1.Items.Count > 0) Then
Dim index As Integer = ListBox1.IndexFromPoint(e.X, e.Y)
Dim strElementOrigin As String = ListBox1.Items(index).ToString()
Dim dde As DragDropEffects = DoDragDrop(strElementOrigin,
DragDropEffects.All)
If dde = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e. X, e.Y))
End If
End If
End Sub

Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub

Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString( )
ListBox2.Items.Add(strElementDestiny)
End If
End Sub

--
Jorge Serrano Pérez
Microsoft MVP VB.NET
PortalVB.com
http://www.portalvb.com/
Weblog de Jorge Serrano
http://weblogs.golemproject.com/jorge/
"JL" wrote:
Thank you Jorge for the response. I did find that article when I ran
Google. And I understand doing drag/drop between controls but not
within a single ListBox so my user can re-order the items in the list.

John

On Sun, 13 Nov 2005 04:36:04 -0800, "Jorge Serrano [MVP VB]"
<NO*******************@NOQUIEROSPAMportalvbNOSPAM. com.NOQUIEROSPAM>
wrote:
Hi,

I think that you'll find useful information about Drag & Drop in the next URL:
http://www.vb-helper.com/howto_net_d...op_object.html

I hope that helps.

Best regards,


Nov 23 '05 #4

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

Similar topics

4
by: John Guarnieri | last post by:
Hi All, I need some code to drag items in a list box either up or down along with not just the text but with the itemdata too. Can anyone hook me up? TIA John
0
by: Lauren Quantrell | last post by:
I'm trying to drop a file from Windows Explorer (or desktop, etc.) onto a field in Access2K and capture the full file path. I found an posting below that says this is possible but I cannot...
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...
3
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== ...
2
by: Barry Moon | last post by:
Hi Can anyone give me any help with passing an object across processes, via drag and drop? I've written a custom ListView control, which supports dragging and dropping of its items. The...
1
by: Manuel Canas | last post by:
Hi there, This is the code that I am using to drag items from a list box and drop them into a text box. I'm not sure, but from what I know, each item on a list box is an object. Let say I get a...
2
by: Dwayne Gaddy | last post by:
Hey all, I have a windows form with a list boxes. I have data binded the list boxes with data from my sql database. I want to use drag and drop to allow users to choose different options from...
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...
1
by: Sim | last post by:
Hello NG, I try to use drag and drop function between two list views. For this I found following code: ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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...
0
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...

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.