473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 1722
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: MrNobody | last post by:
I was a Java developer so I'm used to using property files as a means to keep configuration settings for my apps. I'm wondering what options are there with ..NET? Some settings I want to include...
8
by: Chad Miller | last post by:
lvProjects.Clear() lvProjects.View = View.Details lvProjects.FullRowSelect = True lvProjects.Columns.Add("Id", 50, HorizontalAlignment.Left) lvProjects.Columns.Add("Name", -1,...
1
by: Bill Stillwell | last post by:
I am trying to set the "backcolor" property in fields in a form. It sets okay using a macro (setvalue). But when I close the form, the property settings revert back to what they were before I...
4
by: RedHair | last post by:
I developed a Win form with VS.NET 2005 + .NET 2.0 in C# There are some application settings are "User" scope and stored in xxx.settings, I can access them via Settings class and changethem with...
5
by: spaulsamin | last post by:
Hi I need to set the backcolor to all forms under my project with one command not by opening each form and do it i think , something to do with MDI or Assembly or by some system namespace,...
11
by: tshad | last post by:
I have a Windows form where I am trying to set the BackColor of a control and check the color before I do it: If control.BackColor = System.Drawing.Color.Blue Then ChangeColor(control,...
21
by: omkar pangarkar | last post by:
Hi all, I have two simple hello world programs one using printf() and other using write() --prog 1-- #include<stdio.h> #include<stdlib.h> int main() { printf("Hello"); /* up to here...
4
by: .Net Sports | last post by:
I need to dynamically assign a datalist attribute upon a helper function receiving data from a querystring. If a user picks a certain region, i need the datalist to display its back color, or any...
11
by: =?Utf-8?B?cGJjb2Rlcg==?= | last post by:
Hi, I have been asked to create a solution in a single exe - using C# .NET 3.5. I have found that I can us ILMerge to create a single exe of all of my Application assemblies. But my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.