Resolution: ShowDialog() after ShowDialog().

So.. What can I say? Copy & Paste owned my hiney.

In my previous post, I was bewildered by a behavior I've been seeing where a Dialog box opened from another dialog box would cause the first dialog box to close.

Well, this is partly because of Copy & Paste and partly because I am a moron. When designing forms, I usually copy & paste buttons around since it's the easiest way of having the same exact size for all of them (what can I say, I am lazy). This has the obvious effect of causing all the properties to be copied over. Including the DialogResult property (duh). So I ended up with a bunch of buttons that would close the dialog. So, as (almost) always, .NET is doing exactly what I am asking it to do.

This also explains the fact that when I searched for this behavior, some people were reporting it and others were unable to repro it. It also explains why it only happens "sometimes". Lesson learnt.

Comments (1)

  1. uLavidian says:

    Man… thanks for the post, it helped me heaps… to imagine… hmmm haha

Skip to main content