R
Rune Jacobsen
Hi all,
I think I have just witnessed the strangest thing ever. Sort of.
I have a complex solution upgraded from VS 2003 / .Net 1.1 to VS 2005
(Sp1) / .Net 2.0. The solution consists of a few projects; Some GUI apps
and a few class libraries.
Most stuff works fine, however, I see a very strange problem in the main
GUI app.
In it I have a listview in details/report mode, with 4 columns and a
number of items. These items have UseItemStyleForSubItems all set to
false, because the different items and different columns can all be
colored differently and appear in bold and/or italics depending on their
content.
In VS 2003 this worked perfectly.
In VS 2005, the colors/styles seem to only take partial effect - some
are painted in the proper color/style, others are black and in the
normal font. However, if I move the window off screen or move another
window in front of it and then away, it all looks the way it is supposed
to! If I then click a row, the row I click (plus the one that just got
deselected) returns to being black/normal font.
Ok, so this is weird enough by itself - I can't see why the listview
should behave like this, and of course I checked I am not using some
weird subclassed listview, we're talking System.Windows.Forms.ListView
all the way.
So I made a new solution, with a new project. Added a listview, added
three columns, set it to report/details mode (and yes, that is ALL I did
in the designer). Then I pasted the following simple test code after the
call to InitializeComponent():
for (int i = 1; i <= 10; i++)
{
string m = i.ToString();
ListViewItem itm = new ListViewItem("Item " + m);
itm.SubItems.Add("Fun " + m);
itm.SubItems.Add(m + " stuff");
itm.UseItemStyleForSubItems = false;
itm.SubItems[0].ForeColor = Color.Green;
itm.SubItems[1].ForeColor = Color.Red;
itm.SubItems[2].ForeColor = Color.Blue;
listView1.Items.Add(itm);
}
And what do you know - it works!
So... something is strange in my converted solution, I guess...?
I did exactly the same in one of the existing windows of one of my test
application. The problem occured.
I created a new Windows Form, added a listview and performed the same
steps as above. The problem occured.
I then added a new project to my solution, added a form to it, then
added a listview and the same steps as above. Now it didn't happen -
this time everything worked fine!
So the only conclusion I can draw is that *something* bad is in the
project definition files from my old project that keeps the subitems
from keeping their style/color.
Does anyone know how I can fix this? I would love to be able to have
colored/styled subitems in my listview without having to create
completely new projects...
Thanks in advance!
Rune
I think I have just witnessed the strangest thing ever. Sort of.
I have a complex solution upgraded from VS 2003 / .Net 1.1 to VS 2005
(Sp1) / .Net 2.0. The solution consists of a few projects; Some GUI apps
and a few class libraries.
Most stuff works fine, however, I see a very strange problem in the main
GUI app.
In it I have a listview in details/report mode, with 4 columns and a
number of items. These items have UseItemStyleForSubItems all set to
false, because the different items and different columns can all be
colored differently and appear in bold and/or italics depending on their
content.
In VS 2003 this worked perfectly.
In VS 2005, the colors/styles seem to only take partial effect - some
are painted in the proper color/style, others are black and in the
normal font. However, if I move the window off screen or move another
window in front of it and then away, it all looks the way it is supposed
to! If I then click a row, the row I click (plus the one that just got
deselected) returns to being black/normal font.
Ok, so this is weird enough by itself - I can't see why the listview
should behave like this, and of course I checked I am not using some
weird subclassed listview, we're talking System.Windows.Forms.ListView
all the way.
So I made a new solution, with a new project. Added a listview, added
three columns, set it to report/details mode (and yes, that is ALL I did
in the designer). Then I pasted the following simple test code after the
call to InitializeComponent():
for (int i = 1; i <= 10; i++)
{
string m = i.ToString();
ListViewItem itm = new ListViewItem("Item " + m);
itm.SubItems.Add("Fun " + m);
itm.SubItems.Add(m + " stuff");
itm.UseItemStyleForSubItems = false;
itm.SubItems[0].ForeColor = Color.Green;
itm.SubItems[1].ForeColor = Color.Red;
itm.SubItems[2].ForeColor = Color.Blue;
listView1.Items.Add(itm);
}
And what do you know - it works!
So... something is strange in my converted solution, I guess...?
I did exactly the same in one of the existing windows of one of my test
application. The problem occured.
I created a new Windows Form, added a listview and performed the same
steps as above. The problem occured.
I then added a new project to my solution, added a form to it, then
added a listview and the same steps as above. Now it didn't happen -
this time everything worked fine!
So the only conclusion I can draw is that *something* bad is in the
project definition files from my old project that keeps the subitems
from keeping their style/color.
Does anyone know how I can fix this? I would love to be able to have
colored/styled subitems in my listview without having to create
completely new projects...
Thanks in advance!
Rune