I do not understand why when a dragging operation is started with
DoDragDrop, no exception is handled.
The following lines illustrate what I mean. In Form2_DragDrop event, I raise
an exception at the line "int b=1/a" (so the message After Exception will
not be shown). Why this exception will be unhandled ?
using System;
using System.Windows.Forms;
public class Form2 : System.Windows.Forms.Form {
[STAThread]
static void Main() {
Application.Run(new Form2());
}
public Form2() {
this.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.Form2_ MouseDown);
this.DragDrop += new
System.Windows.Forms.DragEventHandler(this.Form2_D ragDrop);
this.DragEnter += new
System.Windows.Forms.DragEventHandler(this.Form2_D ragEnter);
this.AllowDrop = true;
}
private void Form2_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e) {
DoDragDrop(this,DragDropEffects.All);
}
private void Form2_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e) {
e.Effect=DragDropEffects.Copy;
}
private void Form2_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e) {
int a=0;
MessageBox.Show("Before exception");
int b=1/a;
MessageBox.Show("After exception");
}
}
Ludovic SOEUR