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
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