Solved

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

Posted on 2009-05-19
7
251 Views
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?
0
Comment
Question by:bakerOSU333
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

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

Author Comment

by:bakerOSU333
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...
0
 
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...
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:bakerOSU333
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;
0
 
LVL 96

Accepted Solution

by:
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.
0
 

Author Closing Comment

by:bakerOSU333
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.
0
 
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.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 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