473,804 Members | 4,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[C# Windows Forms] Drag Drop behaviour

Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Hi all,
I have a scenario where i have to drag data from one form to another.
both contain 3rd party gridviews
and the user can select multiple rows.
Data can be dragged and dropped from any grid from either form to another one (infact there are about 6 forms, each with a grid, displaying the same data schema)

I use the mouse down event to capture all the rows selected and start the doDragDrop event for that grid
and have handled the dragDrop event too
for each of the grids.

The issue is that if i click on a grid (click and release) and then go across to the other form and click on it , the data is transferred to that grid (as if it was a drag and drop event)

I did have the queryContinueDr ag event where i captured if the left mouse button was clicked, but this obviously cancelled the evenet the moment i released the mouse.

any possible fixes to this issue?

- the other thing is that once i click once (and release) on a grid, i have to click twice to select something elese in the MDI parent! (the MDI parent is a Ribbon style form)
Nov 16 '07 #1
9 5744
CyberSoftHari
487 Recognized Expert Contributor
You can use
Expand|Select|Wrap|Line Numbers
  1. IResourceWriter
To save data as file to specific path on mouse click (If there is a file already then read it from there and drop it in another form control on click).

Expand|Select|Wrap|Line Numbers
  1. ResourceSet
will read the file content.
Nov 16 '07 #2
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
You can use
Expand|Select|Wrap|Line Numbers
  1. IResourceWriter
To save data as file to specific path on mouse click (If there is a file already then read it from there and drop it in another form control on click).

Expand|Select|Wrap|Line Numbers
  1. ResourceSet
will read the file content.
never wanted to save it to a file!
I dont think that would be required, as the data being dragged isint immensly huge.
Nov 16 '07 #3
CyberSoftHari
487 Recognized Expert Contributor
The only way to drag and drop is to hold the mouse click and release it in another form.

But you want it in mouse down then you have to store data somewhere, if data isn’t huge then store it in database or use a temporary public variable.
Nov 16 '07 #4
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
The only way to drag and drop is to hold the mouse click and release it in another form.

But you want it in mouse down then you have to store data somewhere, if data isn’t huge then store it in database or use a temporary public variable.
Ok, I think I did not make it entirely clear.
The whole drag and drop thing works fine.
The BUG: I click on the grid (and release it) then i go to the other forms grid and click there. The drag event apparantly happens. I dont want this to happen.

I know that my mouse-down event fires the drag event, and the dragDrop event is fired the moment i click on the other grid (when the mouse is clicked and released)

My question here is on how to I go about avoiding this scenario
Nov 16 '07 #5
CyberSoftHari
487 Recognized Expert Contributor
LET ME CLEAR.....!

Did you mean...

Expand|Select|Wrap|Line Numbers
  1. private void ControlName_DragDrop(object sender, DragEventArgs e)
  2.         {
  3.                      e.Data // this wll be your Data which is draged.
  4.  
  5.         }
Is it correct?
Nov 16 '07 #6
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
LET ME CLEAR.....!

Did you mean...

Expand|Select|Wrap|Line Numbers
  1. private void ControlName_DragDrop(object sender, DragEventArgs e)
  2.         {
  3.                      e.Data // this wll be your Data which is draged.
  4.  
  5.         }
Is it correct?
yes, on that event i am checking if the data being dragged is of my object ttype, and then do the drop action.

and thats how I start my drag event
these 2 event handlers are the same code pasted in them
Expand|Select|Wrap|Line Numbers
  1. private void ControlName_MouseDown(object sender, MouseEventArgs e)
  2.         {
  3.             if (e.Button == MouseButtons.Left)
  4.             {
  5.                 //creating object obj
  6.                  ControlName.DodragDrop(obj, DragDropEffects.Move);
  7.             }
  8.         }
cheers
Nov 16 '07 #7
CyberSoftHari
487 Recognized Expert Contributor
Did your problem solved?
Nov 16 '07 #8
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
No,
i posted what i had already.
I thought you were not clear when i posted my query in a pseudo code manner
Nov 16 '07 #9
skrco
1 New Member
Solution to your problem is: use ItemDrag event instead of MouseDown
May 20 '09 #10

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

Similar topics

1
7647
by: Karsten Schramm | last post by:
Hi, if I drag an Outlook.MailItem to a Windows-Explorer window a <subject>.msg file will be created. Now I try to drag & drop a mail item to my own WinForm app. Unfortunately it doesn't work. In the "drop event" are eight DataFormats (e.Data.GetFormats()) but the important one (imho) "FileContents" is "Nothing"/"null".
5
3237
by: IdeaMan | last post by:
Windows 2000 Access 97 I am working on an issue tracking DB, where I need to link (not attach due to size)screen prints of various system errors. I have created a public folder on a network drive to store these images, under the assumption that no one will originally save them to that location. To resolve this, I need to copy the file to this location without possibility of user error in selecting the correct folder (the DB is to be...
5
4976
by: Clyde | last post by:
I am trying to implement the user feedback provided by Windows Explorer when draggng a filename from one place to another. I have the drag and drop action worked out but have had no luck in finding how to capture the piece of the screen into a bitmap to simulate the movement. I know this could be done with the Windows API but can't find any way to do it with .Net functions. Any help is appreciated.
8
15048
by: Chris | last post by:
Hi, In design mode I built some windows with some controls (e.g. listboxes, labels, chgeck boxes etc.) in it, and I did set the property for the window size is set to normal. Now, when I run my app the first user's action is to maximize the window, but the controls inside the window are not resized simultaneously with my window, resulting in a real meshy window.
1
3614
by: Jiang Yue Brandon | last post by:
I am very confused about the different ways of VC++ and C# for doing windows form/dialog design in Visual Studio.NET. In C#, after you drag & drop the components to the form, the underlying codes will be automatically modified to add corresponding objects. However, in VC++, in order to design any forms/dialogs, resources must to be created first, then we need manually
2
6551
by: Harshad | last post by:
Hi, I'm writing a program using Python 2.4 and PyQt4. The aim is to implement drag and drop from filesystem and display a list of files dragged on to the listWidget. This function will later become part of a software for workflow management. When I run the program, DragEnterEvent works as expected, but the DropEvent does not seem to be working. I'm not an experienced Python hacker, and am unable to trace out any problems with the...
0
2133
by: NonNB | last post by:
Hi I have a user control which the user can "drag" across the screen (I'm not using "real" .NET drag drop - instead a single click flavour, where the control is drawn at the mouse position). Depending on whether the user has "picked up" the control or not, I need the following behaviour 1) When the control is being dragged, the control must not intercept
2
1255
by: Aamir | last post by:
Hello, If I have a graphic and I want to allow it to serve as drag source, how do I do this? Imagine that I want to drag from my application to Windows Explorer, so that when I complete the drag-and-drop a file is copied to the given directory. I know the way to do it if I'm using a Windows Form is to implement DoDragDrop(), but what do I do if I am not?
1
5959
by: sCryptKeeper | last post by:
I'm trying to change the cursor while a drag and drop occurs between two lists in a winforms. I tried several ways (several tutorial and solutions) found over the web. I even tried to simply change the cursor when the form loads. But as soon as the mouse moves, the cursor is back to default. I use the following events for my drag and drop. this.MatchRequisitionListView.MouseUp += new...
0
9710
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
10593
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
10329
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
10085
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...
1
7626
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
5663
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4304
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
2
3830
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3000
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.