Solved

Need to bold selected node in Windows Forms TreeView control

Posted on 2011-09-08
3
595 Views
Last Modified: 2012-05-12
I have a Windows Forms project using Visual Studio 2010 with c# and .Net 4.,

When selecting a node on a TreeView control I want the text to be bold.  Similarly when another node is selected the newly selected node should have its text in bold while the previous node is no longer in bold.
0
Comment
Question by:canuckconsulting
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
navneethegde earned 500 total points
ID: 36501852
Hi!

Check if this helps

http://www.longhorncorner.com/Forums/Thread/82383/

Thanks!
0
 

Author Comment

by:canuckconsulting
ID: 36503952
This looks like it would work but in the end I created a custom control inheriting from TreeView and overrode the after select event as follows:

 
protected override void OnAfterSelect(TreeViewEventArgs e)
        {
            if (lastSelectedNode != null)
                lastSelectedNode.NodeFont = new Font(this.Font, FontStyle.Regular);

            if (SelectedNode != null)
                SelectedNode.NodeFont = new Font(this.Font, FontStyle.Bold);

            SelectedNode.Text = SelectedNode.Text; //Hack due to node not displaying all text correctly
            lastSelectedNode = SelectedNode;

            base.OnAfterSelect(e);
        }

Open in new window

0
 

Author Closing Comment

by:canuckconsulting
ID: 36503957
Good advice for drawing but for simple bold I think a custom control was more straight forward.  \
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get month and date in a format 4 44
reading excel file in .net 2 30
How to identify a paragraph in the body of text? 2 49
linq .concat equivalent with expression syntax 4 22
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

735 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