• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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

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?
0
bakerOSU333
Asked:
bakerOSU333
  • 4
  • 3
1 Solution
 
Bob LearnedCommented:
How are you formatting the text?  What .NET version are you using?
0
 
bakerOSU333Author Commented:
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...
0
 
Bob LearnedCommented:
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...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
bakerOSU333Author Commented:
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;
0
 
Bob LearnedCommented:
That sounds like you might have some other code that is resetting the formatting, since that is basic formatting that shouldn't be lost.
0
 
bakerOSU333Author Commented:
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.
0
 
Bob LearnedCommented:
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.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now