【发布时间】:2010-11-01 11:35:21
【问题描述】:
我有一个 WinForms 应用程序,我在其中进行 2 个 TreeView 之间的拖放操作。
在某些时候,我想拒绝底层业务实现中的操作,所以我抛出了一个异常。我可以在输出窗口中看到异常,但问题是我在 UI 中看不到它并且它不会崩溃。
异常去哪儿了?
下面是一些描述问题的代码:
private TreeView tvLeft;
private TreeView tvRight;
private Dictionary<string, int> dico = new Dictionary<string, int>();
void tvLeft_DragDrop(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(typeof(TreeNode))) {
var tnSource = (TreeNode) e.Data.GetData(typeof(TreeNode));
var tnDestination = tvLeft.GetNodeAt(tvLeft.PointToClient(new Point(e.X, e.Y)));
// if I drag-drop the same node twice, there sould be an Exception
// since the key is already in the dictionary...
// ...but I get no Exception in the UI, the Application.ThreadException
// or Appomain.CurrentDomain.UnhandledException handlers
dico.Add(tnSource.Name, (new Random()).Next());
}
}
【问题讨论】:
-
你可能想分享一些代码
标签: c# winforms exception drag-and-drop