Tôi có ứng dụng WinForms nơi tôi đang thực hiện kéo và thả giữa 2 TreeViews.Ngoại lệ bị nuốt khi kéo và thả
Tại một thời điểm nào đó, tôi muốn từ chối hành động trong triển khai kinh doanh cơ bản, vì vậy tôi ném Ngoại lệ. Tôi có thể thấy ngoại lệ trong cửa sổ Output nhưng vấn đề là tôi không thể nhìn thấy nó trong giao diện người dùng và nó không bị treo.
Trường hợp ngoại lệ xảy ra ở đâu?
Dưới đây là một số mã mô tả các vấn đề:
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ó thể bạn sẽ muốn chia sẻ một số mã cho số này – AlexCuse