472,958 Members | 2,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 1686
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.