468,134 Members | 1,214 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,134 developers. It's quick & easy.

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

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

Oct 25 '06 #1
2 1456
Are you using BeginUpdate/EndUpdate? Do you have a simple sample that shows
this behavior?
--
Regards, Peter

"polocar" <po*****@tin.itskrev i meddelandet
news:11**********************@m7g2000cwm.googlegro ups.com...
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

Oct 25 '06 #2
Hi Peter,
yes, I use the BeginUpdate/EndUpdate methods when I start/end to
populate the ListView.
The code I'm using at the moment is very long, but now I'll try to
semplify it and hope that in the semplified version the wrong behaviour
of the ListViewItems BackColor property remains the same...

Oct 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Chad Miller | last post: by
4 posts views Thread by RedHair | last post: by
5 posts views Thread by spaulsamin | last post: by
21 posts views Thread by omkar pangarkar | last post: by
4 posts views Thread by .Net Sports | last post: by
11 posts views Thread by =?Utf-8?B?cGJjb2Rlcg==?= | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.