Can anyone point me to a tutorial on reordering items within a single
listbox using the mouse, ie drag and drop, specifically with vb.net.
Google shows me various half-references eg to related controls, vb6 or
whatever, but nothing that seems to relate specifically to vb.bet and
reordering within a single listbox control.
Thanks
JGD 5 6869
Thanks but that's only a partial solution in that it doesn't (unless
I've missed something) cover the particular circumstance that I'm
stuck on, ie drap and drop _within_ a single listbox in order to
reorder items that are already listed. (And how best to manage the
reordering of items once a DragDrop event has been generated.)
What I most need to know is whether there's a relatively simple
solution to this or alternatively, if not, then I should maybe cut my
losses and try a different approach to the problem, eg by using
up/down cursor keys. But it would be neatest to use drag/drop.
JGD
On Fri, 17 Jun 2005 22:57:05 +0100, "Crouchie19 98"
<cr**********@s pamcop.net> wrote: Hi John,
Here's the solution:
http://support.microsoft.com/default...b;en-us;306969
I hope this helps
Crouchie1998 BA (HONS) MCP MCSE
I pulled this code from one of my personal projects. This should do
what you want. It looks like the second subroutine does nothing, but I
may have needed it for some reason, or it may have been for an idea
that I was working on that I never got back to.
At any rate, watch the word wrapping.
Private Sub lvw_DragDrop(By Val sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles lvw.DragDrop
Try
Dim i As Integer
Dim l_Point As Point = lvw.PointToClie nt(New Point(e.X,
e.Y))
Dim l_Item As ListViewItem = lvw.GetItemAt(l _Point.X,
l_Point.Y)
Dim l_Items() As ListViewItem =
e.Data.GetData( "System.Windows .Forms.ListView Item()")
Dim l_DropIndex As Integer = l_Item.Index
btnDelete_Click (sender, New System.EventArg s)
For Each l_Item In l_Items
lvw.Items.Inser t(l_DropIndex + i, l_Items(i))
i = i + 1
Next
Catch ex As Exception
End Try
End Sub
Private Sub lvw_DragEnter(B yVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles lvw.DragEnter
If e.Data.GetDataP resent("System. Windows.Forms.L istViewItem()")
Then
e.Effect = DragDropEffects .Move
Else
e.Effect = DragDropEffects .None
End If
End Sub
Private Sub lvw_ItemDrag(By Val sender As Object, ByVal e As
System.Windows. Forms.ItemDragE ventArgs) Handles lvw.ItemDrag
Dim myItem As ListViewItem
Dim myItems(sender. SelectedItems.C ount - 1) As ListViewItem
Dim i As Integer = 0
' Loop though the SelectedItems collection for the source.
For Each myItem In sender.Selected Items
' Add the ListViewItem to the array of ListViewItems.
myItems(i) = myItem
i = i + 1
Next
' Create a DataObject containg the array of ListViewItems.
sender.DoDragDr op(New
DataObject("Sys tem.Windows.For ms.ListViewItem ()", myItems),
DragDropEffects .Move)
End Sub
Sorry, I didn't notice at first that you stated a listbox instead of a
listview. I don't use listboxes, so I don't know if that my above code
will work for you.
Sorry, I didn't notice at first that you stated a listbox instead of a
listview. I don't use listboxes, so I don't know if that my above code
will work for you. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
by: Eric |
last post by:
I'm trying to implement Drag and Drop with objects in list boxes and I'm not having any success. I can drag and drop strings, but when I try to change the code to drag an object it allows me to pick up the object and the mouse changes when I get over a place that will accept the drop but when I let go of the mouse button it sits there for about 3 seconds then the mouse turns to the normal pointer and the object isn't listed in the drop listBox...
|
by: CoolWriter |
last post by:
Hi,
How can I drag and drop the items of a ListBox?
For example, how can I drag the first item to the third items position
in a ListBox?
Thanks.
|
by: L.Peter |
last post by:
Dear Group,
I am doing Drag and Drop function and see this problem
if I select 3 from listBox1 and drag to listBox2, the value in listBox1 is
not updated, even I move (or use up and down keyboard) to select number 4,
the selectedItem.ToString() still shows 3
Am i doing something wrong?
Here is the file
****
using System;
|
by: Dean Slindee |
last post by:
In a checked listbox, I am allowing drag/drop of the items within
(resequencing). Problem is, when dropping a checked item, the checked state
always reverts to unchecked (unwanted). Anyone know how to set the checked
state of a checked listbox item in code. Here is the drag/drop code, which
works fine, except for unchecking the dropped item:
Private Sub clbQueryItems_DragDrop(ByVal sender As System.Object, ByVal e As...
| |
by: Zyrthofar Blackcloak |
last post by:
Hi everyone
I have a listbox with more items in it than is printed on screen. I
need the index number of the first shown item to move another listbox
to the same position... Explained differently, the two listboxes have
the same number of items, and are linked and show the same portion to
the screen.
I have been having problems with a listbox in which we can drag&drop
items to different indexes, at the same time as being able to...
|
by: Bernie Yaeger |
last post by:
I've been able to get a pair of listboxes to pass data from one to the other
successfully, but only one selected item at a time. If I change the listbox
mode of both the multiextended, it only passes the item (point) from which
the drag begins. Here's some of the relevant code:
Dim Pt As New Point(e.X, e.Y)
Dim Index As Integer
' Determines which item was selected.
|
by: John Dann |
last post by:
I'm still struggling to find a way of reordering the items within the
same single listbox with drag and drop. I think I've got the drag
working but it's the drop code I can't figure out. What I have
currently is (with the listbox set to AllowDrop):
Sub MyListBox_MouseDown(args etc...)
DoDragDrop(MyListBox.SelectedItem, DragDropEffects.Move)
End Sub
Sub MyListBox_DragEnter(args etc...)
|
by: thomasp |
last post by:
Has anyone got some sample code to do drag and drop from one listbox to
another listbox using VB.Net 2005. The below code works for draging and
droping one at a time, but not for multiselected items. I tried setting up
an array to capture the selected items and then move them with the dragndrop
code, but after selecting the items when the user clicks on the items to
drag them the selection goes back to one item. Also I have code for the...
|
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,...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
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...
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |