473,793 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4771
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************ *******@NOQUIER OSPAMportalvbNO SPAM.com.NOQUIE ROSPAM>
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(ByVa l sender As System.Object, ByVal e As
System.EventArg s) 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.AllowD rop = True
End Sub

Private Sub ListBox1_MouseD own(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListBox1.MouseD own
If (ListBox1.Items .Count > 0) Then
Dim index As Integer = ListBox1.IndexF romPoint(e.X, e.Y)
Dim strElementOrigi n As String = ListBox1.Items( index).ToString ()
Dim dde As DragDropEffects = DoDragDrop(strE lementOrigin,
DragDropEffects .All)
If dde = DragDropEffects .All Then
ListBox1.Items. RemoveAt(ListBo x1.IndexFromPoi nt(e.X, e.Y))
End If
End If
End Sub

Private Sub ListBox2_DragOv er(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles ListBox2.DragOv er
e.Effect = DragDropEffects .All
End Sub

Private Sub ListBox2_DragDr op(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles ListBox2.DragDr op
If e.Data.GetDataP resent(DataForm ats.StringForma t) Then
Dim strElementDesti ny As String =
e.Data.GetData( DataFormats.Str ingFormat).ToSt ring()
ListBox2.Items. Add(strElementD estiny)
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************ *******@NOQUIER OSPAMportalvbNO SPAM.com.NOQUIE ROSPAM>
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
8492
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
2605
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 simutate it. Can anyone help? Thanks ************************** previous post: Message 1 in thread
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?
3
10420
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== using System; using System.Drawing; using System.Collections; using System.ComponentModel;
2
4501
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 drag and drop works fine within the same application, but fails
1
1602
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 bunch of names display on a list box now, how do I get the text of each item to drop that text into a text box? Private Sub lstResult_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles...
2
1613
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 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 binded list boxes ? If it is possible do you know of any place on...
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 ?
1
5378
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchimpdragdrop.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
0
9671
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
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
10000
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
9035
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...
1
7538
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
6777
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
5436
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
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
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.