ListBox, Double-Click and Closing Form

G

Guest

OK, here's a mystery for you guys. It's a bug, I'm sure, but my question is:
is there a workaround?

Set up a Double-click event handler for a ListBox. In that event handler,
either close the form (this.Close()) or call another method that closes it,
doesn't matter.

You get an error:

An unhandled exception of type 'System.ObjectDisposedException' occurred in
system.windows.forms.dll

Additional information: Cannot access a disposed object named "ListBox".

This only seems to happen for ListBoxes. I tried it with a ListView and a
DataGrid and everything worked fine.

Any workarounds?

TIA,
~~Bonnie
 
G

Guest

OK, well, I just found out that the guy who originally had this problem (I
posted this here in order to try and help the guy), is using this form as a
modal dialog (which, if I had thought about it a little more, I would have
realized from the get-go), so I told him that he doesn't need to close it.
Just perform the click of his accept button.

Still, I wonder if there is any other way around this (in case there is a
legitimate need for this kind of functionality)?

~~Bonnie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top