以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  我想让目录树中选中的节点的字体变成粗体!  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=83890)

--  作者:大红袍
--  发布时间:2016/4/19 11:55:00
--  

AfterSelectNode事件

 

Dim tree As System.Windows.Forms.TreeView = e.Sender.basecontrol


For i As Integer = tree.Controls.Count - 1 To 0 Step -1
    If tree.Controls(i).Name = "SelectLab" Then
        tree.Controls.RemoveAt(i)
    End If
Next

Dim selCon As  System.Windows.Forms.Control = tree.Controls("SelectLab")
Dim label As New System.Windows.Forms.Label
label.Name = "SelectLab"
label.AutoSize = False
label.BackColor = Color.Red
label.ForeColor = e.Node.ForeColor
label.Font = new font(tree.Font.name, tree.Font.size, FontStyle.Bold )
tree.Controls.Add(label)
selCon = Label
Dim node As System.Windows.Forms.TreeNode = tree.SelectedNode
selCon.Size = new Size(node.Bounds.Width+5, node.Bounds.Height)
selCon.Location = new Point(node.Bounds.X, node.Bounds.Y)
selCon.Text = e.Node.Text


--  作者:大红袍
--  发布时间:2016/4/19 14:43:00
--  

Dim tree As System.Windows.Forms.TreeView = e.Sender.basecontrol


For i As Integer = tree.Controls.Count - 1 To 0 Step -1
    If tree.Controls(i).Name = "SelectLab" Then
        tree.Controls.RemoveAt(i)
    End If
Next

Dim selCon As  System.Windows.Forms.Control = tree.Controls("SelectLab")
Dim label As New System.Windows.Forms.Label
label.Name = "SelectLab"
label.AutoSize = False
label.BackColor = Color.Red
label.ForeColor = e.Node.ForeColor
label.Font = new font(tree.Font.name, tree.Font.size, FontStyle.Bold )
label.TextAlign = 2
tree.Controls.Add(label)
selCon = Label
Dim node As System.Windows.Forms.TreeNode = tree.SelectedNode
selCon.Size = new Size(node.Bounds.Width+5, node.Bounds.Height)
selCon.Location = new Point(node.Bounds.X, node.Bounds.Y)
selCon.Text = e.Node.Text