Guest Krzychu Posted October 7, 2002 Posted October 7, 2002 Hi All! I'm from Poland. I am beginner programmer in Visual Basic .NET. I want, that all TreeNodes in my treeview control will be underlined. Is someone can help me? Quote
*Experts* Bucky Posted October 7, 2002 *Experts* Posted October 7, 2002 Sure! You just need to set the NodeFont property of each node to a new font that is created with the FontStyle Underlined. When you add nodes to the treeview, create a new font object that is based on the TreeView's Font and with FontStyle.Underline as the new style. Then set this font object to the node's NodeFont property and add it to the TreeView. You could also create a recursive subroutine that loops through all the nodes, after they are added, and underlines them by using the same method. In this example, tn is the TreeNode to add to the TreeView (tvw), and f is the Font object to create from the TreeView's font. Dim tn As New TreeNode() ' The Node to add Dim f As New Font(tvw.Font, FontStyle.Underline) ' The new font for the node tn.NodeFont = f ' Set the node's font tvw.Nodes.Add(tn) ' Add the node Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* divil Posted October 7, 2002 *Gurus* Posted October 7, 2002 Or, you could just set the font of the treeview to an underlined one. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Guest Krzychu Posted October 9, 2002 Posted October 9, 2002 Thanks for Your code, but I need a whole area of TreeNode to be underlined, not only a text (just like in PropertyGrid Control). Quote
*Experts* Bucky Posted October 10, 2002 *Experts* Posted October 10, 2002 Well, if you want to make the treeview look like a grid, that isn't possible without a lot of code (I don't think owner-drawing TreeView items in VB.NET is possible without the Windows API). If you want a grid-looking control, try the ListView. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.