How do I keep a ListView's text formatting from changing?

Posted on 2009-05-19
Last Modified: 2012-05-07
On my form, I have a button that when clicked opens up a log file in notepad.  When this happens, if I go back to my form where the ListView is located, all of the text formatting has been reset to just normal basic text.  However, if I highlight any row or all rows, the formatting returns to the way I want it.  Is there a way to keep this from never changing so that it doesn't have to be selected in order to go back to the way I put it?
Question by:bakerOSU333
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 96

Expert Comment

by:Bob Learned
ID: 24431271
How are you formatting the text?  What .NET version are you using?

Author Comment

ID: 24431951
I'm formatting the text just using Fonts in the C# code (bold, colors, etc.), and I believe I'm using .NET 2.0 in Visual Studio 2005...
LVL 96

Expert Comment

by:Bob Learned
ID: 24438055
Is this an owner-drawn ListView, or are you just using standard formatting in code?  I am looking for the right context to understand your problem.  A little code might help to explain your problem...
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now


Author Comment

ID: 24441840
I'm just using the standard Windows ListView, and here is a few lines of the code I'm using to adjust the font information:

Font errorFont = new Font(FontFamily.GenericSansSerif, (float)8.25, FontStyle.Regular);
ListViewItem item = lvLog.Items.Find(e.TreeItem, false)[0];
int i = item.Index;
item.Text = item.Text.Replace("Processing", "Error(s)");
ListViewItem errorItem = lvLog.Items.Insert((i + 1), "          " + e.FileLog);
errorItem.Font = errorFont;
errorItem.ForeColor = Color.Red;
LVL 96

Accepted Solution

Bob Learned earned 500 total points
ID: 24446592
That sounds like you might have some other code that is resetting the formatting, since that is basic formatting that shouldn't be lost.

Author Closing Comment

ID: 31583187
I appreciate the info LearnedOne, thanks so much, I'll just dig through the code and find out where I'm changing any focus and possibly resetting the formatting.
LVL 96

Expert Comment

by:Bob Learned
ID: 24451479
If that code that you showed me before is what you are using to format, I would suggest taking that code out, and creating a simple test project/form, to see that the formatting shouldn't be getting lost.

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor ( Top Charts is a view in which you can set seve…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question