| ||||||||
| Home > Software > Drag-n-Drop Using Visual Basic > Introduction | ||||||||
|
Visual Basic 6 : Drag-n-Drop Tutorial Introduction1.1 What is Drag & DropIn computer graphical user interface drag & drop is the action of clicking on an object (virtual object on screen) and dragging it to a different location (on screen) as required. The basic sequence involved in drag & drop is
The drag-n-drop is programmatically done and it is widely used in creating objective type questions. Both VB6 and VB.NET support a rich variety of drag drop functions as detailed in the following three examples. Example: An example of a simple drag and drop sequence is given below. Fig1 contains two columns: First column contains animal names, and the second column contains small boxes where user needs to drop the relevant images.
Animal Name
Boxes where relevant images are dropped Fig 1. Images before being dragged to the target Fig 2. gives after the images being dragged and dropped to the correct places.
Fig 2. Images after being dragged to the target 1.2 The Basic Concepts of Drag and DropA drag-and-drop operation involves a source object and a target object. The source object can be any Visual Basic control, and the target object can be any control or the form itself. The operation has three parts:
1.3 Properties of Drag & DropControls have two properties that are related to drag-and-drop:
Executing the Drag method on the source control is required only when it’s Drag mode property is set to vbManual. The syntax for this method is:
Set action to vbBeginDrag (value = 1) to initiate a drag operation. This will usually be done in the source control's MouseDown event procedure. You can also call the Drag method with action set to vbCancel or vbEndDrag (values 0 and 2 respectively) to cancel an ongoing drag-and-drop operation or to end a drag-and-drop operation. Controls have two events that are related to drag-and-drop. DragOver is used to detect when an object is dragged over a control, and DragDrop is used to detect when an object is dropped on a control:
Target identifies the target object (the one being dragged over or dropped on). It can be a form, an MDI form, or a control. If the target is a control that is part of a control array, these event procedures will have an additional argument that specifies the Index property of the control within the control array. Source identifies the source control (where the drag-drop operation began). X and y gives the horizontal and vertical position of the mouse pointer with respect to object. These values are always expressed according to the object's coordinate system State specifies the relationship between the mouse pointer and the target, as follows:
When a source control is dragged and dropped, here's what happens:
1.4 System RequirementsThe example codes given in the tutorial runs on any Windows computer running XP, 2000, or Vista. Project is done in Visual Basic 6 as front end and Microsoft Access2000 as back end. The tutorial is primarily intended for use by VB programmers, and you may be requiring VB6 software installed on your computer to run the program. | ||||||||
| ||||||||
| Home Copyright (C) 2003-2011 TutorialsWeb.com Disclaimer Sitemap | ||||||||