473,790 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1750
Are you using BeginUpdate/EndUpdate? Do you have a simple sample that shows
this behavior?
--
Regards, Peter

"polocar" <po*****@tin.it skrev i meddelandet
news:11******** **************@ m7g2000cwm.goog legroups.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
5987
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 are like a root directory for a target program on the user's machine my app uses, which they would be prompted to supply at startup. Normally the registry is used for this but I'd rather not use the registry if possible. Isn't there some kind of...
8
9076
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, HorizontalAlignment.Left) lvProjects.Columns.Add("Last Used", 100, HorizontalAlignment.Center) lvProjects.Columns.Add("Status", 100, HorizontalAlignment.Center) Dim Item1 As New ListViewItem("001", 0) Item1.SubItems.Add("ABC Soliciters")...
1
3210
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 closed the form. So when I reopen the form, the settings are not changed. If I manually change the settings while not in Design mode (using the "fill with" icon), the settings hold. If I change the settings while in Design mode, the settings do not...
4
3596
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 Settings.Save(); However, if I change and save them then my app will read the change from the user.config , my question is how to access the original default setting?
5
2340
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, but i am not sure
11
1931
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, Color.Red) Else ChangeColor(control, Color.Blue) End If But I get an error:
21
2459
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 write() isn't called, if u * give \n here then two write()s will
4
2204
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 of its other objects , as a certain color or css style <HeaderStyle BackColor="<%= ssponcont %>"</HeaderStyle> ....doesnot work as a Parser error renders: Content ('<HeaderStyle
11
3091
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 question is what to do about settings/config? I have some settings should be settings which should be shared between
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9986
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3707
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.