473,412 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Question on HandleDestroyed event

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_It em(Int32 displayIndex)
at System.Windows.Forms.ListView.OnHandleDestroyed(Ev entArgs 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(M essage& 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.
One other question.

According to the stack trace, 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
Nov 27 '06 #1
1 1817
It looks like you have not instantiated the ListView properly. Check your
code or you want to paste some here perhaps.

chanmm

"Flack" <Fl***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...
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_It em(Int32
displayIndex)
at System.Windows.Forms.ListView.OnHandleDestroyed(Ev entArgs 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(M essage& 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.
One other question.

According to the stack trace, 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
Nov 28 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Csaba2000 | last post by:
How do I achieve the following in javascript, the emphasis being on the NN (6.1) 'event' parameter that needs to be declared? This is the current method - works just fine: <TABLE border...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
0
by: Mike hofer | last post by:
I am studying up for my MCAD, and came across an interesting conundrum. According to my textbook, there are FOUR steps to publish an event: 1. Define a delegate type that specifies the prototype...
3
by: cmay | last post by:
In reading some documents from the Patterns and Practices group, I had a question about the example given for the Page Controller pattern. (I have posted the code for the BasePage below) In...
2
by: andrew007 | last post by:
I have a question about dataset rowfilter. I have a list of event table in a database. each event has start-date and end-date column. I grab these from db and save to dataset. And then I have to...
4
by: Hardy Wang | last post by:
Hi, I have two classes (ClassA and ClassB), public ClassA { public ClassA() { this.MyButton.Clicked += new System.EventHandler(this.MyButton_Click); } private void MyButton_Click(object...
3
by: jm | last post by:
>From a C. Petzold book I have Programming Windows C#. It's a little old now, but anyway, it has on page 71 (shortened): form.Paint += new PaintEventHandler(MyPaintHandler); static void...
2
by: Flack | last post by:
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: ...
4
by: tshad | last post by:
I am just getting started with events and had a couple of questions on why they do what they do. If you have a textbox and you want to handle an event you can just do: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.