ListView bug

S

Shaun Wilde

I can only assume what I am going to describe to be a bug as it only
happens on the CF and not in normal Full Framework (yes I tested)

If I add a ListViewItem that has more SubItems then the ListView has
Columns then the CF takes it upon itself to change those extra
SubItems to "". i.e. erasing the content of those SubItems.

I have added the pertinant code below - the form consists of 1
ListView containing 1 ColumnHeader and the listview is set to Details.

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//

ListViewItem item = new ListViewItem("hello");
item.SubItems.Add("more data");

listView1.Items.Add(item); // damage happens here

foreach (ListViewItem it in listView1.Items)
{
MessageBox.Show(it.SubItems[0].Text + " " +
it.SubItems[1].Text); // this is where you can see the subItem has
gone on the CF
}

}

If there is a KB article on this I have yet to find it!

NOTE: Further investigation (using the debugger and watch window)
shows that the line the damage occurs is listView1.Items.Add(item)
NOTE2: Also trying to add or modify the unused SubItem after adding
the item to the ListView.Items collection thows various exceptions.

Anyone think of a workaround?

Shaun
 
A

Armin Sadeghi [MSFT]

Thanks for bringing this to our attention, we will investigate.

Workaround - add your subitems after the top level ListViewItem to avoid
losing the text.

-Armin

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Shaun Wilde)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: ListView bug
| Date: 3 Sep 2003 07:53:19 -0700
| Organization: http://groups.google.com/
| Lines: 45
| Message-ID: <[email protected]>
| NNTP-Posting-Host: 212.137.57.41
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062600800 29521 127.0.0.1 (3 Sep 2003
14:53:20 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 3 Sep 2003 14:53:20 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!sn-xi
t-02!sn-xit-06!sn-xit-08!sn-xit-09!supernews.com!postnews1.google.com!not-fo
r-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32653
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I can only assume what I am going to describe to be a bug as it only
| happens on the CF and not in normal Full Framework (yes I tested)
|
| If I add a ListViewItem that has more SubItems then the ListView has
| Columns then the CF takes it upon itself to change those extra
| SubItems to "". i.e. erasing the content of those SubItems.
|
| I have added the pertinant code below - the form consists of 1
| ListView containing 1 ColumnHeader and the listview is set to Details.
|
| public Form1()
| {
| //
| // Required for Windows Form Designer support
| //
| InitializeComponent();
|
| //
| // TODO: Add any constructor code after InitializeComponent call
| //
|
| ListViewItem item = new ListViewItem("hello");
| item.SubItems.Add("more data");
|
| listView1.Items.Add(item); // damage happens here
|
| foreach (ListViewItem it in listView1.Items)
| {
| MessageBox.Show(it.SubItems[0].Text + " " +
| it.SubItems[1].Text); // this is where you can see the subItem has
| gone on the CF
| }
|
| }
|
| If there is a KB article on this I have yet to find it!
|
| NOTE: Further investigation (using the debugger and watch window)
| shows that the line the damage occurs is listView1.Items.Add(item)
| NOTE2: Also trying to add or modify the unused SubItem after adding
| the item to the ListView.Items collection thows various exceptions.
|
| Anyone think of a workaround?
|
| Shaun
|
 
S

Shaun Wilde

Thanks for bringing this to our attention, we will investigate.

You're welcome - I just hope it isn't me being daft - you should find
the problem easy to reproduce - I am also running the .NET CF SP1 on
an iPAQ
Workaround - add your subitems after the top level ListViewItem to avoid
losing the text.

If you mean change the order to

listView1.Items.Add(item);
item.SubItems.Add("more data");

then it throws an ArgumentOutOfRangeException on the CF

If I try this

item.SubItems.Add("more data");
listView1.Items.Add(item);
item.SubItems[1].Text=("more data");

then it throws a generic Exception

Shaun
 
A

Armin Sadeghi [MSFT]

After some investigation it seems that the Compact Framework does not
support having more subitems than columns. If an 'extra' subitem is added
after adding a ListViewItem to a ListView then an exception is thrown.

If you want to associate additional information with listviewitems you have
to create your own listview item class inherited from the ListViewItem
class. Or you could set up your columns first.

-Armin

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Shaun Wilde)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: ListView bug
| Date: 4 Sep 2003 04:56:59 -0700
| Organization: http://groups.google.com/
| Lines: 26
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
| NNTP-Posting-Host: 212.137.57.41
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062676620 7881 127.0.0.1 (4 Sep 2003
11:57:00 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 4 Sep 2003 11:57:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-08!sn-xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32747
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| (e-mail address removed) (Armin Sadeghi [MSFT]) wrote in message
| > Thanks for bringing this to our attention, we will investigate.
|
| You're welcome - I just hope it isn't me being daft - you should find
| the problem easy to reproduce - I am also running the .NET CF SP1 on
| an iPAQ
|
| > Workaround - add your subitems after the top level ListViewItem to
avoid
| > losing the text.
|
| If you mean change the order to
|
| listView1.Items.Add(item);
| item.SubItems.Add("more data");
|
| then it throws an ArgumentOutOfRangeException on the CF
|
| If I try this
|
| item.SubItems.Add("more data");
| listView1.Items.Add(item);
| item.SubItems[1].Text=("more data");
|
| then it throws a generic Exception
|
| Shaun
|
 
S

Shaun Wilde

Hi Armin

I know it doesn't support it but since its behaviour is different to that of
the Full Framework then to me that is a bug.

I know the CF is a cut down version of the Full Framework but what
API/methods it does support it should treat them in the same way.

There is no reason for the behaviour to be different between the frameworks
and the fact that it is different means that someone went out
of their way to make it so (or couldn't follow the original spec). If this
is by "design" then it should definitely be documented and highlighted
that this is a difference in behaviour.

However .NET is supposed to be portable and if I use the valid API for a
platform within my assembly then I should expect the behaviour
to be the same for all platforms I run the code on. Since this is not the
case - then to me it is wrong.

Shaun

Armin Sadeghi said:
After some investigation it seems that the Compact Framework does not
support having more subitems than columns. If an 'extra' subitem is added
after adding a ListViewItem to a ListView then an exception is thrown.

If you want to associate additional information with listviewitems you have
to create your own listview item class inherited from the ListViewItem
class. Or you could set up your columns first.

-Armin

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Shaun Wilde)
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: Re: ListView bug
| Date: 4 Sep 2003 04:56:59 -0700
| Organization: http://groups.google.com/
| Lines: 26
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
| NNTP-Posting-Host: 212.137.57.41
| Content-Type: text/plain; charset=ISO-8859-1
| Content-Transfer-Encoding: 8bit
| X-Trace: posting.google.com 1062676620 7881 127.0.0.1 (4 Sep 2003
11:57:00 GMT)
| X-Complaints-To: (e-mail address removed)
| NNTP-Posting-Date: 4 Sep 2003 11:57:00 GMT
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-08!sn-xit-09!supernews.com!postnews1.google.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:32747
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| (e-mail address removed) (Armin Sadeghi [MSFT]) wrote in message
| > Thanks for bringing this to our attention, we will investigate.
|
| You're welcome - I just hope it isn't me being daft - you should find
| the problem easy to reproduce - I am also running the .NET CF SP1 on
| an iPAQ
|
| > Workaround - add your subitems after the top level ListViewItem to
avoid
| > losing the text.
|
| If you mean change the order to
|
| listView1.Items.Add(item);
| item.SubItems.Add("more data");
|
| then it throws an ArgumentOutOfRangeException on the CF
|
| If I try this
|
| item.SubItems.Add("more data");
| listView1.Items.Add(item);
| item.SubItems[1].Text=("more data");
|
| then it throws a generic Exception
|
| Shaun
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top