Which of the following code segments is used to write code to begin a drag-and-drop operation?

You are busy to develop a Microsoft Windows Forms application that allows the computer engineers to design circuit boards for different types of hardware. The electronic parts exits as nodes, on the main form, which reside in a TreeView control named testtreeView.
The TreeView’s AllowDrop property is set to false and a Panel control provides the drawing surface.
You want the Development users to drag the components to the drawing surface. Which of the following code segments is used to write code to begin a drag-and-drop operation?

You are busy to develop a Microsoft Windows Forms application that allows the computer engineers to design circuit boards for different types of hardware. The electronic parts exits as nodes, on the main form, which reside in a TreeView control named testtreeView.
The TreeView’s AllowDrop property is set to false and a Panel control provides the drawing surface.
You want the Development users to drag the components to the drawing surface. Which of the following code segments is used to write code to begin a drag-and-drop operation?

A.
testtreeView.DragEnter += delegate[object sender, DragEventArgs e] {
DoDragDrop[e.Data, DragDropEffects.Copy];
}

B.
testtreeView.DragLeave += delegate
{
DoDragDrop[testtreeView.SelectedNode, DragDropEffects.Copy]; }

C.
testtreeView.DragEnter += delegate[object sender, DragEventArgs e] {
DoDragDrop[e.Item, DragDropEffects.Copy];
}

D.
testtreeView.DragEnter += delegate[object sender, DragEventArgs e] {
DoDragDrop[testtreeView.SelectedNode, DragDropEffects.Copy]; }

Explanation:
If you handle the ItemDrag event of the TreeView control, an event will raise when the user begins to drag a node in the TreeView control.

Incorrect Answers:
A, D: The MouseEnter event of the TreeView control should not be used. It will raise an event every time the mouse pointer entersthe area which is occupied by the TreeView control. The DragEnter event of the TreeView control should not be used, because the AllowDrop is set to false.



Leave a Reply 0

Your email address will not be published. Required fields are marked *