Solved

Need to bold selected node in Windows Forms TreeView control

Posted on 2011-09-08
3
611 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
[X]
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
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Navneet 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

622 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