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!