Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need to bold selected node in Windows Forms TreeView control

Posted on 2011-09-08
3
Medium Priority
?
620 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 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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 …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

670 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