ListView problems

  • Thread starter Thread starter Alessandro
  • Start date Start date
A

Alessandro

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

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 !
 
Since you only create a CMPC_Fields object, but never actually populate it
anywhere, it seems that null is appropriate (unless the ctor is doing
something).

-Chris
 
ok, the CMPC_Fields object was created and its property setted, i have only
obmited the code

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 !
 
Please note that number of columns in ListView should be greater or equal
to the number of subitems. Columns should be added before adding subitems.

Hope this helps.
Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: "Alessandro" <[email protected]>
| References: <#[email protected]>
<[email protected]>
| Subject: Re: ListView problems
| Date: Tue, 14 Oct 2003 14:31:39 +0200
| Lines: 33
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: 193.205.214.41
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:35920
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| ok, the CMPC_Fields object was created and its property setted, i have
only
| obmited the code
|
| 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 !
|
|
|
 
Back
Top