473,394 Members | 1,642 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,394 software developers and data experts.

List View variable throwing NullException

Hello,

I've added a list view to a windows form and I want to add items and
subitems to the list at runtime. The problem that I have is that when
I try to use the list view control variable it throws the following
error

An unhandled exception of type 'System.NullReferenceException'
occurred in RcvrStatusTest.exe

Additional information: Object reference not set to an instance of an
object.
I created the list view control by using the design wizard. So, I
used the variable the was generated by the design wizard.

(exception thrown here) ListView1 = gcnew ListView(); (If I were to
comment out this line the exception will be thrown on the next line
that contains ListView1)

(Here)ListViewItem^ lviName= ListView1->Items->Add("Michael
Beasley");
lviName->SubItems->Add("101 Lance Court");
lviName->SubItems->Add("000-000-0000");

Does anyone have any suggestions?

Mar 28 '07 #1
2 2179

<Mi**********@gmail.comwrote in message
news:11**********************@n59g2000hsh.googlegr oups.com...
Hello,

I've added a list view to a windows form and I want to add items and
subitems to the list at runtime. The problem that I have is that when
I try to use the list view control variable it throws the following
error

An unhandled exception of type 'System.NullReferenceException'
occurred in RcvrStatusTest.exe

Additional information: Object reference not set to an instance of an
object.
I created the list view control by using the design wizard. So, I
used the variable the was generated by the design wizard.
The wizard creates code to create subcontrols in InitializeComponent. If
you try using any of your child controls before InitializeComponent runs,
you'll have that error.
Mar 28 '07 #2
On Mar 28, 6:15�pm, "Ben Voigt" <r...@nospam.nospamwrote:
<Miesha.Ja...@gmail.comwrote in message

news:11**********************@n59g2000hsh.googlegr oups.com...


Hello,
I've added alistviewto a windows form and I want to add items and
subitems to thelistat runtime. *The problem that I have is that when
I try to use thelistviewcontrolvariableit throws the following
error
An unhandled exception of type 'System.NullReferenceException'
occurred in RcvrStatusTest.exe
Additional information: Object reference not set to an instance of an
object.
I created thelistviewcontrol by using the design wizard. *So, I
used thevariablethe was generated by the design wizard.

The wizard creates code to create subcontrols in InitializeComponent. *If
you try using any of your child controls before InitializeComponent runs,
you'll have that error.- Hide quoted text -

- Show quoted text -
Thank you so much Ben! I believe that has fixed the problem!

Mar 29 '07 #3

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

Similar topics

8
by: Ward B | last post by:
Greetings all. I'm getting the following error message... Unknown column 'icaodesc' in 'field list' when I try to update a table from a PHP form. What 'field list' is it referring to? My...
19
by: RAJASEKHAR KONDABALA | last post by:
Hi, Does anybody know what the fastest way is to "search for a value in a singly-linked list from its tail" as oposed to its head? I am talking about a non-circular singly-linked list, i.e.,...
10
by: Zack Sessions | last post by:
Has anyone tried to create a SQL7 view using the CREATE VIEW command and ADO.NET? If so, is there a trick in trapping a SQL error when trying to create the view? I have a VB.NET app that, amoung...
15
by: Andrew Brampton | last post by:
Hi, This may sound a odd question, but I wanted to know how you return a list of data from a function. These are some of the ways I know how, and I was wondering which method you normally use....
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
17
by: 2005 | last post by:
Hi In C++, are the following considered best practices or not? - passing aguments to functions (ie functions do not take any arguments ) - returning values using return statement Anything...
1
by: Miesha.James | last post by:
Hello, I'm trying to rewrite visual c++ code into visual c++ .NET code and I've run across a problem with storing objects into a list. Here;s an example of the code I have: ref struct...
5
by: googletired | last post by:
On my current site, I can click on a category and the view the content of that category. This is fine, but now I want to be able to view the contents of *ALL* the categories in one continous scroll...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.