Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9005591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:11:14+00:00 2026-06-16T01:11:14+00:00

This is a case of weird behaviour. I’m calling a TreeView_Drag_Drop event (I don’t

  • 0

This is a case of weird behaviour.
I’m calling a TreeView_Drag_Drop event (I don’t think the type of event is relevant but whatever). Inside my event I call 3 MessageBox in a row. Like this :

MessageBox.Show("A");
MessageBox.Show("B");
MessageBox.Show("C");

The output will be B and C.
If I put a breakpoint on MessageBox.Show("A"); it will stop there but won’t pop the MessageBox.

If I replace my code for this :

Console.WriteLine("A");
MessageBox.Show("B");
MessageBox.Show("C");

The ouput will be this A (in the console), B,C.

My last try is to make a dummy MessageBox to see if the compiler only rules out the first box he sees. So I replaced my code for this :

MessageBox.Show("Kill this box");
MessageBox.Show("A");
MessageBox.Show("B");
MessageBox.Show("C");

The output is A,B, C.

Is there a simple explanation for this without any further code ? (Anyway that’s the only code in the event) because I just can’t explain this behaviour.


Update with another test

I tried putting them in a foreach loop.

foreach ( // logic )
{
  MessageBox.Show("A");
  MessageBox.Show("B");
  MessageBox.Show("C");
}

For my first iteration, the output will be B, C.
But for all the other iterations, the output will be A,B,C. Like it already ruled out one MessageBox so it’s okay to go through.


Code Update

This code works perfectly on a prototype. But the exact same code doesn’t in my program.
Please note that for multiple language support and stuff the forms are called by reflexion. (Don’t think that’s relevant at all but anyway).

    private void Form1_Load(object sender, EventArgs e)
    {
        treeView1.Nodes.Add("Test");
        this.treeView1.ItemDrag += new ItemDragEventHandler(this.treeView_ItemDrag);
        this.treeView2.ItemDrag += new ItemDragEventHandler(this.treeView_ItemDrag);
        this.treeView1.DragEnter += new DragEventHandler(this.treeView_DragEnter);
        this.treeView2.DragEnter += new DragEventHandler(this.treeView_DragEnter);
        this.treeView1.DragDrop += new DragEventHandler(this.treeView_DragDrop);
        this.treeView2.DragDrop += new DragEventHandler(this.treeView_DragDrop);
    }

    private void treeView_DragEnter(object sender,
        System.Windows.Forms.DragEventArgs e)
    {
        e.Effect = DragDropEffects.Move;
    }

    private void treeView_ItemDrag(object sender,
        System.Windows.Forms.ItemDragEventArgs e)
    {
        DoDragDrop(e.Item, DragDropEffects.Move);
    }

    private void treeView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
    {

        MessageBox.Show("A");
        MessageBox.Show("B");
        MessageBox.Show("C");

    }

I know it works. The problem is it doesn’t in my program and it’s Exactly the same code. I’m looking for any possible reasons why it would behave differently in my solution but I can’t find anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:11:15+00:00Added an answer on June 16, 2026 at 1:11 am

    DragAndDrop event

    Any exception raised in them is swallowed without any diagnostic. The probable philosophy behind that is that they are likely to fail because they handle data that is produced by another program. And that a buggy program that produces bad data like that should not be allowed to crash yours.

    If you need to debug your code then use Debug + Exceptions, tick the Thrown checkbox for CLR exceptions. The debugger will now stop when the exception is thrown.

    If you want the user to know about any exceptions then you’ll need to use try/catch to catch the exception before it is swallowed. With the slight risk that any bugs in another program become yours to explain.

    I found this on a similar question. Finally.. this behaviour is so hard to debug.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I encountered some very weird behaviour which I think is a bug, but I
This is a fairly weird case, you can see the code here: http://jsfiddle.net/zpZtH/2/
In this case, is it bad to subscribe to the proxy CloseCompleted event? public
Imagine this case, but with a lot more component buckets and a lot more
Now this is going to be a little weird use-case. Maybe someone has some
This is probably intended behaviour or atleast not a jQuery / js issue but
I've found weird behaviour in PHPs foreach loop. When I do it like this:
This case is a bit complex, I hope I will simplify it well. My
In this case the character is ^ . For example in the following format
In this case, the source of the text is from a winforms textbox. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.