473,508 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rearrange the order of a listbox with the mouse

Can anyone tell me how to code the listbox so I can move an item up and down
the listbox with the mouse. For example, the play list in Winamp 5 can be
sorted by you selecting a song and moving it up or down the play list by
selecting it with the mouse and dragging it where you want.
The list box gets the contents from a .txt file. (if you need more info
please let me know)

Many Thanks
Nick

Nov 22 '05 #1
2 4243
Well basically you need to drag and drop the listbox items. What you
need to do is that when the item is dragged and dropped you need to
remove the item from the listbox using Remove() method and then insert
it at the new location using the Insert() method of the listbox.

For more info on how to drag and drop see the following articles
http://www.c-sharpcorner.com/winform...AndDrop2MG.asp
http://www.codeproject.com/cs/combob...ragAndDrop.asp
http://www.ondotnet.com/pub/a/dotnet...1/dragdrop.htm
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Nick Stubbs wrote:
Can anyone tell me how to code the listbox so I can move an item up and down
the listbox with the mouse. For example, the play list in Winamp 5 can be
sorted by you selecting a song and moving it up or down the play list by
selecting it with the mouse and dragging it where you want.
The list box gets the contents from a .txt file. (if you need more info
please let me know)

Many Thanks
Nick

Nov 22 '05 #2
Well basically you need to drag and drop the listbox items. What you
need to do is that when the item is dragged and dropped you need to
remove the item from the listbox using Remove() method and then insert
it at the new location using the Insert() method of the listbox.

For more info on how to drag and drop see the following articles
http://www.c-sharpcorner.com/winform...AndDrop2MG.asp
http://www.codeproject.com/cs/combob...ragAndDrop.asp
http://www.ondotnet.com/pub/a/dotnet...1/dragdrop.htm
Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Nick Stubbs wrote:
Can anyone tell me how to code the listbox so I can move an item up and down
the listbox with the mouse. For example, the play list in Winamp 5 can be
sorted by you selecting a song and moving it up or down the play list by
selecting it with the mouse and dragging it where you want.
The list box gets the contents from a .txt file. (if you need more info
please let me know)

Many Thanks
Nick

Nov 22 '05 #3

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

Similar topics

1
377
by: Nick Stubbs | last post by:
Can anyone tell me how to code the listbox so I can move an item up and down the listbox with the mouse. For example, the play list in Winamp 5 can be sorted by you selecting a song and moving it...
0
1883
by: tommazzo | last post by:
I'm currently writing a photo album sotware in C#. I'm using a ListView component to diaplay thumbnail previews of the photos and want to give the user the possibility to rearrange the photos via a...
6
29980
by: Dan Bass | last post by:
If you look at explorer, right clicking on a file, first selects the file, then throws up the context menu relating to that selection. With a Windows ListBox control and a simple context menu,...
0
2581
by: AK | last post by:
Hello, Listbox mulitselect property is set to true (extended). I am trying to implement drag and drop feature for a listbox. The drag & drop is done in the mouse move event (DoDragdrop...
4
2524
by: Alan Silver | last post by:
Hello, I have a repeater showing a list of items and I would like to be able to allow the user to change the order of the items. I have absolutely no idea how to go about this, other than having...
2
1927
by: hazz | last post by:
is there a way to have a re-arrangeable list with an asp.net control ? I would like to have a list of database table column values in an ordered list initially loaded by their column order in the...
18
4582
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
2
1278
by: laxwrestler27 | last post by:
Hello everyone, I'm creating a program for a courier service that takes info from a database to make a 2d array with the necessary info, then puts that on to an excel spreadsheet per delivery. ...
6
7201
by: GS | last post by:
how can I set tooTip on ToolTip1 for a listbox?
4
2717
by: simion314 | last post by:
Hi, i need to use a owner draw listbox(i am using windows forms in NET 2.0 ). I created a testlistbox ,implemented the DrawItem method and it works fine, it scrolls with the mouse wheel. After that i...
0
7125
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
7328
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,...
1
7049
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
7499
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
4709
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...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
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 ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
422
bsmnconsultancy
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...

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.