Performing drag & drop operation in a Windows Forms app

In a Windows Forms application, a drag-and-drop functionality refers to the transferring of data with the mouse. It enables a user to drag data such as a text, an image, or other object with the mouse’s left-button from one control and drop it to another control. This functionality is an event-driven process that occurs when the data is copied from the source control and when the data is dropped onto the target control. The source as well as target control events are involved in implementing the drag-and-drop operations are as follows:

  • Source Control Events: These events occur when a mouse pointer triggers some action on a source control. The following are the source control events:

    . To get a glimpse of these PrepKits, you can download its free demo version (which contains 15 free practice questions) from:

    Download link: https://www.ucertify.com/exams/Microsoft/70-526-VB.html

    1. MouseDown Event: It occurs when the mouse button is pressed and the mouse pointer is over the source control. A method that handles this event calls the DoDragDrop method of the source control.
    2. GiveFeedback Event: It occurs when a drag-and-drop operation is initiated. The appearance of the mouse pointer can be modified by the source of a drag event. In this event, a user can obtain the visual feedback during the operation. This event provides a custom mouse pointer to a user.
    3. QueryContinueDrag Event: It occurs during a drag-and-drop operation. It is raised when the keyboard or the mouse button state changes during the operation. It also enables the drag source in order to determine whether the drag-and-drop operation is cancelled.
  • Target Control Events: These events occur when a mouse pointer triggers some action on a target control. The following are the source control events:
    1. DragEnter Event: It occurs when an object is dragged into the bounds of the target control. It is raised when the mouse cursor is first dragged over the target control during a drag-and-drop operation.
    2. DragOver Event: It occurs when an object is dragged over the bounds of the target control. It is raised when the mouse cursor is within the bounds of the control.
    3. DragDrop Event: It occurs when the mouse button is released over the target control and a drag-and-drop operation is completed.
    4. DragLeave Event: It occurs when the an object is dragged out of the bounds of the target control. It occurs when the current drag-and-drop operation is cancelled.

Sequence of a Drag-and-Drop Operation

The following is the general sequence of events that take place in a drag-and-drop operation:

  1. The drag-and-drop operation is initiated by calling the DoDragDrop method within the MouseDown event handler on the source control. The method contains two parameters, namely the Object data that specifies the desired data to pass and the DragDropEffects data value that specifies a particular drag operation on a control. The method determines under which control the current mouse cursor is located. It then checks whether the valid drop target operation has been performed. In this sequence, a new DataObject object is automatically created.
  2. The GiveFeedback event is raised when a custom mouse pointer is displayed during the dragging operation. The QueryContinueDrag event is raised to determine whether the drag operation should be continued or aborted.
  3. The drop-and-drop operation is allowed when the AllowDrop property is set to true in the Properties window at design time. The property can be set to true programmatically in the Form_Load event of a Windows form.
  4. The DragEnter event for a target control is raised when the mouse cursor is first dragged over the control. The DragOver event takes place when a mouse pointer stays over the bounds of a control.
  5. Finally, the DragDrop event is raised when the mouse button is released over a valid target control. In the Windows form, the event handler extracts the appropriate data from the DataObject object. Data is then displayed in the target control.

DragDropEffects Enumeration Values

The DragDropEffects enumeration identifies the effects of a drag-and-drop operation in a Windows Forms application. It contains the FlagsAttribute attribute that enables a user to perform a bitwise combination of its member values. It is used by the DragEventArgs, GiveFeedbackEventArgs, and Control classes. The following are the member values that can exist in this enumeration:

Member Values Description
All During a drag-and-drop operation data is copied, dragged, and removed from the source control. The data is then scrolled and dropped onto the target control.
Copy During a drag operation, data is copied to the target control.
Link During the operation, data from the source control is linked to the target control.
Move During the operation, data is moved from the source control to the target control.
None During a drag-and-drop operation, the target control does not accept the data from the source control.
Scroll During a drag-and-drop operation, the scrolling operation is initiated or is currently being performed.

Implementing Drag-and-Drop Operations between Applications

Generally, a drag-and-drop operation is performed within a single Windows Forms application. This operation can also be implemented between two applications. The following conditions should be fulfilled in order to enable a drag-and-drop operation between applications:

  • A target control should allow one of the drag effects being specified when the DoDragDrop method is called.
  • A target control should accept data in the same format that was set when the DoDragDrop method is called.

Implementing Drag-and-Drop Operations by using a TreeView Control

The implementation of a drag-and-drop operation in a TreeView control is slightly different from other controls. When a drag operation is initiated on a TreeView node, the ItemDrag event is raised. The event passes an instance of ItemDragEventArgs to a method that handles this event. The ItemDragEventArgs object contains a reference that is copied to the DataObject object in the DoDragDrop method.

Download link: https://www.ucertify.com/exams/Microsoft/70-526-VB.html

Vikram Reviewed uCertify 70-536 CSHARP Course

Vikram Ramanathan has been working in the software industry for the past 7 years. He has worked on a variety of technologies/platforms such as Flash, Photoshop, Linux, VB6, and .NET. Currently, He is working on a Legacy application created on VB6 with Xml as its back end. He is doing the certification as part of his Individual Development Plan for his company and also increase his .NET knowledge. He has one or two home projects, which he is doing to improve his technical skill level in .NET.

After reviewing the uCertify PrepKit for the exam 70-536, he concluded that “Overall, it was a pleasant experience using uCertify Prep Engine. Previously I had used Microsoft’ PrepKit. It was refreshing to use uCertify’s Prep Kit for a change. Though, I have not fully explored uCertify’s Prep Engine, I am certainly happy with what I have seen and learnt. Now It’s “Certify” time for me and hope to with study with full steam and clear the exams with with flying colors.”

You can read the complete review on uCertify 70-536 CSHARP PrepKit at Vikram’s Blog.

Things to practice for Microsoft test 70-528 CSHARP

The 70-528 test measures an individual’s ability to develop and implement ASP.NET Web applications using .NET Framework 2.0. Before taking the 70-528 test, you should practice the following:

  1. Create a new Web application and add Web Forms pages to the application.
  2. Add Web server controls to a Web Form and configure their properties programmatically.
  3. Create event handlers for a page or control at design time.
  4. Manage state of an application by using client-based and server-based state management options.
  5. To analyze the capabilities of the software, you can download a demo version and evaluate it free of cost. For more information, please visit: 70-528-C# .NET 2.0 Web-based Application Development

    Continue reading “Things to practice for Microsoft test 70-528 CSHARP”

Everything you want to know about 70-526 (CSHARP)

Q: What are the prerequisites for taking the exam 70-526 (CSHARP)?

A: Before taking the exam, you should have at least one year of experience in developing Windows-based applications by using the Microsoft .NET Framework version 2.0. You should also have a working knowledge of Visual Studio 2005.

Q: Which programming languages can you choose for this exam?

A: You can choose the Microsoft Visual C# 2005 programming language for this exam. Other programming languages are Microsoft Visual Basic 2005 and Microsoft Visual C++ 2005.

To get a glimpse of these PrepKits, you can download its free demo version (which contains 15 free practice questions) from:

Download link: https://www.ucertify.com/exams/Microsoft/70-526-CSHARP.html
Continue reading “Everything you want to know about 70-526 (CSHARP)”

Everything you want to know about 70-536 Application Development Foundation

Q. What is MCTS: .NET 2.0 Application Development Foundation exam?

A. Microsoft’s 70-536 is designed to test your knowledge of the Microsoft .NET Framework 2.0 fundamentals. The 70-536 exam measures your skills that include developing applications, implementing service processes, threading, and application domains, embedding configuration, diagnostic, management, and installation features into a .NET Framework application, etc. After passing this test along with the other core exams, you will become an MCTS: .NET 2.0 Web Applications, MCTS: .NET 2.0 Windows Applications or MCTS: .NET 2.0 Distributed Applications.

To analyze the capabilities of the software, you can download a demo version and evaluate the PrepKit free of cost. Click the link below:

Download link:https://www.ucertify.com/exams/Microsoft/70-536-CSHARP.html

Continue reading “Everything you want to know about 70-536 Application Development Foundation”