Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2007

Tip: Looking for answers? Try searching our database.

List View variable throwing NullException

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Miesha.James@gmail.com - 28 Mar 2007 22:43 GMT
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?
Ben Voigt - 28 Mar 2007 23:15 GMT
> Hello,
>
[quoted text clipped - 11 lines]
> 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.
Miesha.James@gmail.com - 29 Mar 2007 03:38 GMT
> <Miesha.Ja...@gmail.com> wrote in message
>
[quoted text clipped - 21 lines]
>
> - Show quoted text -

Thank you so much Ben!  I believe that has fixed the problem!

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.