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

Help with _DragDrop on listbox?

Subject: Help with DoDragDrop event?
From: Alex <me******@test.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Hi all,

I'm having a problem with drag/drop on listboxes... basically I created
a user control that is used to create many listboxes on the form
dynamically at runtime. Each of these is assigned a unique value for
employee.

When an item is dragged from one listbox to another, a row in the db is
updated to reflect the employee change and the listboxes then refresh
from the db & the item is shown in the dragged to listbox.

The problem I'm having is that on a single click on an item, the update
and refresh are happening. I'd like to supress this action in the case
of a simple selection versus doing it when a drag to another listbox is
actually done.

Here's some code:

I'm trying to find the employee from the dragfrom listbox and compare it
to the employee on the dragto listbox in order to supress the action, but
when I access it via the 'sender' object in _DragDrop, I get the employee
on the dragto listbox.

This does work when I don't have that conditional in there, but I get
extra updates and refreshes every time I single click.

Should the sender object in _DragDrop reference the object that I dragged
from?

Thanks!
private void listBoxTeamMember_DragEnter(object sender,
DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text)) //replace with
listbox row type
{
e.Effect = DragDropEffects.Move;
}
}
private void listBoxTeamMember_DragDrop(object sender,
DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
{
//do it and refresh

int iDragFromEmpSKey;
iDragFromEmpSKey = Convert.ToInt32
(((System.Data.DataRowView)(((System.Windows.Forms .ListBox)
(sender)).SelectedItem))["AssignedEmployeeSKey"]);
//don't dragdrop within the same listbox
if (! (iDragFromEmpSKey == EmployeeSKey ))
{

DMG.AssignmentDraggedToEmployee
(e.Data.GetData(DataFormats.Text).ToString(),

EmployeeSKey, EmployeeUnitID);
//refresh window to show changes
ptr_RefreshFromTeamSelection.DynamicInvoke(null);
}
}
}
private void listBoxTeamMember_MouseDown(object sender,
MouseEventArgs e)
{

if (MouseButtons == MouseButtons.Left)
{
listBoxTeamMember.DoDragDrop(((DataRowView)
listBoxTeamMember.SelectedItem)["AssignmentSKey"].ToString(),
DragDropEffects.Move);
}
}

Dec 1 '06 #1
0 1511

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

Similar topics

1
by: Vengeance | last post by:
On the parent_form.aspx I have these controls <asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox> <INPUT class="loButton" onclick="java...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
7
by: Dave Hopper | last post by:
Hi I posted a question recently regarding problems I am having getting a value from a list box to use in a query. I got a lot of help, for which I thank you and it's nearly working! But I need...
3
by: Paul T. Rong | last post by:
I have a listbox (of product names) control on my form. I want to pass the selected item (a product name) to a subform, and the product unitprice should apear automatically next to the product name...
5
by: Melissa Cowan | last post by:
I am using Access 2000. I have the Developer's handbook and got the code for the mulit select listbox from there. It sends the selected value to another listbox, lstselected. What I need to do is...
0
by: David J | last post by:
Hi, I am strugling with the propertygrid and a listbox. I am using the universaldropdowneditor from the codeproject (code below). However I am populating the listbox via a datasource. The problem...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
0
by: Alex | last post by:
Hi all, I'm having a problem with drag/drop on listboxes... basically I created a user control that is used to create many listboxes on the form dynamically at runtime. Each of these is...
2
by: Phijo | last post by:
Hello, I am writing a page (C#) that uses one ListBox that retrieves data from a DB using SqlDataSource and the SelectCommand. <asp:SqlDataSource ID="DataSource1" SelectCommandType=Text...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.