473,569 Members | 2,648 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 4252
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 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...
0
1901
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 drag&drop operation. The problem is that it only appears to be possible to rearrange items in a ListView if its view property is not set to...
6
29998
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, the default behaviour seems to display the context menu on the listbox, but there is no selection. Now I know that explorer's using a listview, and...
0
2586
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 function is called in mouse move event). I am facing two problems: 1. First is that when shift key is pressed and left mouse button is down. The listbox...
4
2527
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 a pair of Move Up/Down buttons, which would result in a postback for every single move. This would be very slow and frustrating for a user trying...
2
1930
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 table HOWEVER have the ability to use an arrow or some mechanism to rearrange the order of the columns so that when a report is created, the...
18
4587
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 function, or one calls the other. Isn't there an event for 'ListBox selection selected' that is automatically called by ALL the standard GUI ways of...
2
1281
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. I have already finished coding that part and it works like a charm. What I would like to do is to have the user be able to rearrange the items on the...
6
7203
by: GS | last post by:
how can I set tooTip on ToolTip1 for a listbox?
4
2733
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 created the same kind of listbox but i added more complex code in DrawItem and my listbox wont scroll with the mouse whell or with the arrows keys, i...
0
7701
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...
0
7615
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...
0
7979
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...
0
6284
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...
1
5514
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...
0
5219
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...
1
2115
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
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.