473,379 Members | 1,423 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,379 software developers and data experts.

Drag and Drop in a ListBox control

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.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 15 '05 #1
5 9567
Dan
look into the DragDrop event. this gives you access to the items being dragged in, and you can specify how they get added to your listbox

http://msdn.microsoft.com/library/de...agdroptopic.as

--Dan
Nov 15 '05 #2
Here is a great example

http://www.codeproject.com/cs/miscct...ewreorder1.asp
Nov 15 '05 #3
Here is a great example

http://www.codeproject.com/cs/miscct...ewreorder1.asp
Nov 15 '05 #4
ta*******@superonline-dot-com.no-spam.invalid (CoolWriter) wrote in message news:<40**********@Usenet.com>...
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.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Add these two events to your listbox and declare object thing as a
public variable
public void listBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
int temp;
temp = listBox1.SelectedIndex;
listBox1.Items.Remove(thing);
listBox1.Items.Insert(temp, thing);
}

public void listBox1_MouseDown(object
sender,System.Windows.Forms.MouseEventArgs e )
{
int temp;
temp = listBox1.SelectedIndex;
thing = listBox1.Items[temp];
}
Nov 15 '05 #5
ta*******@superonline-dot-com.no-spam.invalid (CoolWriter) wrote in message news:<40**********@Usenet.com>...
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.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Add these two events to your listbox and declare object thing as a
public variable
public void listBox1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
int temp;
temp = listBox1.SelectedIndex;
listBox1.Items.Remove(thing);
listBox1.Items.Insert(temp, thing);
}

public void listBox1_MouseDown(object
sender,System.Windows.Forms.MouseEventArgs e )
{
int temp;
temp = listBox1.SelectedIndex;
thing = listBox1.Items[temp];
}
Nov 15 '05 #6

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

Similar topics

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...
0
by: Spare Change | last post by:
I've set up a form with a TextBox and a ListBox ( You can see all code here: http://home.earthlink.net/~jabailo/Windopes%20SupaText/ ) Right now, if you double-click and select text in the...
4
by: Qingdong Z. | last post by:
I have a VS.NET windows application which use drag-drop feather. It works fine when application start, but stops working after application run one or two days. The application is related to Video...
3
by: Demetri | last post by:
If one were to develop a web server control (web control library), which enhances the datagrid by implementing a class that inherits from the DataGrid class, and give it drag and drop capability. ...
1
by: Kevin L | last post by:
I have a Panel control that I currently allow the user to drag and reposition on a form at runtime. This Panel control contains a Label control. I would like to allow the user to drag the PANEL...
0
by: Bernie Yaeger | last post by:
OK, I have drag-drop working between one listbox and another (and back) with the code below. But I can't get it to work when I change the selection mode to multi or multi extended. Any help...
5
by: Brian Henry | last post by:
I haven't worked much with drag/drop but I am trying to make a form that accepts files to drug onto it from explorer and droped and have the form know the full path and file name of the files...
0
by: **Developer** | last post by:
Has anyone found out how to do DragDrop from a ListBox with SelectionMode.MultiExtended I've been searching Google and see that it is an old problem. I know from past experience that it stems...
2
by: cse_supriya | last post by:
hii i have a problemm.. do help mee. i want the user to drag n drop items from one listbox to another listbox......n it has to be a web application... i mean i m using asp.net..... do reply...
0
by: Pesso | last post by:
I'm loading a text file to a RichTextBox control to drag a selection of a text and drop it into a tree view control. It works except after the drag and drop operation the RichTextBox scrolls to the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.