473,770 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

drag and drop datasource 2 listboxes

77 New Member
i have two listboxes, lbData and lbTo. i need to drag and drop between the two.

lbData.datasour ce = tblfilter;

i need to be able to drag and drop the data from one to the other then on the other listbox display the same text but still have the same value behind. so when i submit the lbTo data should read something like

Smith John 7A with a value of 657576

for each person in the lbTo.

i currently have a drag and drop code but it dont let me drop onto lbTo it appears with a circle with a line through it.

Expand|Select|Wrap|Line Numbers
  1. private void lbData_MouseDown(object sender, MouseEventArgs e)
  2.         {
  3.  
  4.             lbData.DoDragDrop(lbData.Text, DragDropEffects.Move);
  5.  
  6.  
  7.         }
  8.  
  9.         private void lbData_DragEnter(object sender, DragEventArgs e)
  10.         {
  11.             if(e.Data.GetDataPresent(DataFormats.Text))
  12.             {
  13.                 e.Effect = DragDropEffects.Move;
  14.             }
  15.             else
  16.             {
  17.                 e.Effect = DragDropEffects.None;
  18.             }
  19.         }
  20.         private void lbData_DragDrop(object sender, DragEventArgs e)
  21.         {
  22.             lbData.Text = (string)e.Data.GetData(DataFormats.Text);
  23.         }
also it may be useful for you to know the listbox properties so here they are.

Expand|Select|Wrap|Line Numbers
  1. // 
  2.             // lbData
  3.             // 
  4.             this.lbData.AllowDrop = true;
  5.             this.lbData.Location = new System.Drawing.Point(8, 120);
  6.             this.lbData.Name = "lbData";
  7.             this.lbData.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
  8.             this.lbData.Size = new System.Drawing.Size(184, 342);
  9.             this.lbData.TabIndex = 9;
  10.             this.lbData.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbData_MouseDown);
  11.             this.lbData.DragDrop += new System.Windows.Forms.DragEventHandler(this.lbData_DragDrop);
  12.             this.lbData.DragEnter += new System.Windows.Forms.DragEventHandler(this.lbData_DragEnter);
  13.             // 
  14.             // lbTo
  15.             // 
  16.             this.lbTo.AllowDrop = true;
  17.             this.lbTo.Location = new System.Drawing.Point(216, 120);
  18.             this.lbTo.Name = "lbTo";
  19.             this.lbTo.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
  20.             this.lbTo.Size = new System.Drawing.Size(184, 342);
  21.             this.lbTo.TabIndex = 10;

what will i ahve to do to modify this code to work how i need?

All answers are greatly apprecieated.

Many Thanks,
Piercy
Aug 16 '07 #1
0 1385

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1286
by: Karuppasamy | last post by:
Hi In a Windows Applications, i want to drag and drag multiple items between two Listboxes. Is it possible to drag and drop multiple items? If yes, how to do that? Waiting for your reply.
3
10413
by: Ajay Krishnan Thampi | last post by:
I have a slight problem implementing 'drag and drop' from a datagrid to a tree-view. I have pasted my code below. Someone please advice me on what to do...pretty blur right now. ==code== using System; using System.Drawing; using System.Collections; using System.ComponentModel;
3
8170
by: James Radke | last post by:
Hello, I was curious, is it possible to create drag and drop interface from listbox to listbox on a webform application (i.e. vb.net)? Basically the application would need to load multiple listboxes with values from a database, allow the user to drag and drop from a listbox to a different listbox and would 'move' the item and update the database accordingly? If so, would anyone have any examples of how to do this?
6
4961
by: James Allen Bressem | last post by:
I was searching through the MSDN documentation trying to figure out how to do drag n drop and I found a sample program. The sample program did all sorts of fancy junk like dynamically create it's user controls etc. (pomp - is it really necessary to be so gaudy when trying to explain a simple point?) So, realizing the state of the economy and the period of history in which I was so unfortunately born, I spent the next 3 or so hours weeding...
7
2501
by: Sam | last post by:
Hi, I've done the method described here : http://64.78.52.104/FAQ/WinForms/FAQ_c87c.asp#q565q It works well for items added at design time. However if my source list is filled with a datasource, the items are properly displayed but the method private void OnDragEnter(object sender,
2
1611
by: Dwayne Gaddy | last post by:
Hey all, I have a windows form with a list boxes. I have data binded the list boxes with data from my sql database. I want to use drag and drop to allow users to choose different options from the list boxes on the form and drag them into another empty list box that is not bound to any data when the form loads. I was wondering is it possible to use drag and drop with data binded list boxes ? If it is possible do you know of any place on...
3
10598
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
4
2560
by: Full NameEntry | last post by:
Hi all, I'm new to csharp... learning it by muddling my way though examples. In my current example, I'm trying to make a form with a bunch of listboxes that have drag and drop enabled amongst them... I found an example online in the form of a DragNDrop.cs file that I've included in my project (attached below).
2
1320
by: CNemo | last post by:
Hello friends! I need to do subj and VS03. No Atlas or something like this. Would be great if somebody may share a small sample how to do it. What i have in mind is like: 1. Create hidden field to hold source control name. 2. When mouse down, store name in this control. 3. Drag. 4. When drop, do postback from target control.
0
9617
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9453
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,...
0
10254
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, 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...
1
10036
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,...
0
9904
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8929
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7451
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
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...
1
4007
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 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.