Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C# ListViewItems lose their BackColor settings when I run the exe file

Status
Not open for further replies.

polocar

Programmer
Sep 20, 2004
89
IT
Hello,
I’m developing a C# program using Visual Studio 2005 Professional Edition.
In the main form I have inserted a ListView control that is populated in a different way depending on the item selected in a ComboBox.
I have written a procedure that reads the ComboBox selected item and populates the ListView according to that. The procedure uses a “for” cycle: in every iteration it creates a ListViewItem, set its SubItems and BackColor properties and add it to the ListView (the BackColor is set to a color that depends on various factors).
When I run the program from Visual Studio everything goes ok, but when I run the program from the .exe file created after the code generation, in some cases the ListViewItems appear without their BackColor. If I select the ListViewItems one by one, they finally take the BackColor they should have been from the beginning.
The strange things are two:

1) The ListViewItems are without their BackColor only in some cases, not all of them (if I select an item of the ComboBox, the ListView is populated correctly; if I select the next item, the ListView is populated without any BackColors), but it can’t depend on the code!!! (the way it handles the two cases is the same).

2) If the project runs under Visual Studio 2005, there is no bug, the ListView is always populated with its ListViewItems having their correct BackColors…

Do you know the reason of that?
Can someone help me to avoid this unpleasant behaviour when I run the .exe file too?

Thank you very much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top