以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  设置treeview目录树,各层level的支点的字体大小  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=72839)

--  作者:阿福
--  发布时间:2015/8/7 11:40:00
--  设置treeview目录树,各层level的支点的字体大小
如何设置treeview目录树,各层level的支点的字体大小,
例如
level属性为0时,各支点的字体为12
level属性为1时,各支点的字体为11
level属性为2时,各支点的字体为10
请问,各位师傅如何做?


--  作者:大红袍
--  发布时间:2015/8/7 12:19:00
--  

全局代码

 

Public Sub myTreeView_DrawNode(ByVal sender As Object, ByVal e As Windows.Forms.DrawTreeNodeEventArgs)
If e.Node.Level = 0
    e.Graphics.DrawString(e.Node.Text, new font("宋体", 15), Brushes.Red, e.Bounds)
Else If e.Node.Level = 1
    e.Graphics.DrawString(e.Node.Text, new font("宋体", 8), Brushes.Blue, e.Bounds.x, e.Bounds.y + 5)
Else
    e.Graphics.DrawString(e.Node.Text, new font("宋体", 8), Brushes.Blue, e.Bounds.x, e.Bounds.y + 5)
End If

End Sub

 

调用代码

 

Dim trv As windows.forms.treeview = e.Form.Controls("TreeView1").basecontrol
trv.font = New Font("宋体",15)
trv.DrawMode = Windows.forms.TreeViewDrawMode.OwnerDrawText
addHandler trv.DrawNode, addressof myTreeView_DrawNode


--  作者:阿福
--  发布时间:2015/8/7 14:38:00
--  
谢谢大红袍字体如果要加粗可以
 e.Graphics.DrawString(e.Node.Text, new font("宋体", 15,FontStyle.Bold ), Brushes.Red, e.Bounds)

[此贴子已经被作者于2015/8/7 14:43:07编辑过]

--  作者:大红袍
--  发布时间:2015/8/7 14:44:00
--  

参考

 

http://www.foxtable.com/help/topics/0494.htm

 

http://www.foxtable.com/help/topics/1482.htm

 


--  作者:阿福
--  发布时间:2015/8/7 14:47:00
--  
谢谢你,大红袍!!!