HandleDestroyed event

G

Guest

Hey guys.

Under what circumstances is HandleDestroyed called? Is it only called when
a control is being Disposed?

I sometimes get the following exception in my app:

UnhandledThreadException, Exception='System.NullReferenceException: Object
reference not set to an instance of an object.
at System.Windows.Forms.ListViewItemCollection.get_Item(Int32 displayIndex)
at System.Windows.Forms.ListView.OnHandleDestroyed(EventArgs e)
at System.Windows.Forms.Control.WmDestroy(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ListView.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)'

Has anyone seen this before or have any ideas on how I can debug it? It
happens randomly and rarely so I can't reproduce it.

Thanks
 
G

Guest

One other question.

According to the stack trace in my previous post, it seems that one of the
items in the listview is null.

Can someone give me an exmaple of how I can get a null value in the
listview's item collection in the first place?

Trying to add "null" directly throws its own exception and I can't figure
out how to add a non-null value and then somehow get it to be null.

Anyone have a short example of that happening?

Thanks a lot
 

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