472,989 Members | 3,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 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 9547
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...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.