I have a big problem with ListView: if i add subitmes them they are null...

Here the code to populate the listview:


For i = 0 To Total - 1
Dim oListViewItem As ListViewItem
Dim oField As New CMPC_Fields

oField.FLDS_ID = odataset.tables(0).rows(i).item("FLDS_ID")
oField.Order = odataset.tables(0).rows(i).item("Order ")
oField.Removable = odataset.tables(0).rows(i).item("Removable ")

oListViewItem = New ListViewItem
oListViewItem.Checked = oField.Visible

oListViewItem.Text = "test _" & i

oListViewItem.SubItems.Add(oField.FLDS_ID.ToString)
oListViewItem.SubItems.Add(oField.Order.ToString)
oListViewItem.SubItems.Add(oField.Removable.ToString)

Me.LSVfields.Items.Add(oListViewItem)
Next

if then i do:
Me.LSVfields.Items(0).count --> i have to correct number of subitmes;
LSVfields.Items(0).SubItems(0) --> i have the correct text: test_0
LSVfields.Items(0).SubItems(1) --> i have nothing
LSVfields.Items(0).SubItems(2) --> i have nothing
LSVfields.Items(0).SubItems(3) --> i have nothing

i don't understand why !

Re: List view Problem ! by Mark

Mark
Wed Oct 15 07:03:51 CDT 2003

I believe the listview control has to have columns defined for each of the
subitems (even if you aren't using the "detail view"). So, make sure you
have 4 columns defined (the main item and the 3 sub items) and see if that
helps.

- Mark

"Alessandro" <gemini_two@hotmail.com> wrote in message
news:eH2Fm6lkDHA.976@tk2msftngp13.phx.gbl...
> I have a big problem with ListView: if i add subitmes them they are
null...
>
> Here the code to populate the listview:
>
>
> For i = 0 To Total - 1
> Dim oListViewItem As ListViewItem
> Dim oField As New CMPC_Fields
>
> oField.FLDS_ID = odataset.tables(0).rows(i).item("FLDS_ID")
> oField.Order = odataset.tables(0).rows(i).item("Order ")
> oField.Removable = odataset.tables(0).rows(i).item("Removable
")
>
> oListViewItem = New ListViewItem
> oListViewItem.Checked = oField.Visible
>
> oListViewItem.Text = "test _" & i
>
> oListViewItem.SubItems.Add(oField.FLDS_ID.ToString)
> oListViewItem.SubItems.Add(oField.Order.ToString)
> oListViewItem.SubItems.Add(oField.Removable.ToString)
>
> Me.LSVfields.Items.Add(oListViewItem)
> Next
>
> if then i do:
> Me.LSVfields.Items(0).count --> i have to correct number of
subitmes;
> LSVfields.Items(0).SubItems(0) --> i have the correct text: test_0
> LSVfields.Items(0).SubItems(1) --> i have nothing
> LSVfields.Items(0).SubItems(2) --> i have nothing
> LSVfields.Items(0).SubItems(3) --> i have nothing
>
> i don't understand why !
>
>
>