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

Posted on 2009-05-19
Medium Priority
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...
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

771 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