首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

treeview展开有关问题

2012-01-29 
treeview展开问题我想把treeview前面的“+”号去掉,然后点击根节点就显示所有子节点,再点击就合拢,初始时tre

treeview展开问题
我想把treeview前面的“+”号去掉,然后点击根节点就显示所有子节点,再点击就合拢,初始时treeview是合拢的,请问各位该怎么做?????

[解决办法]
rootnode.Expanded = true; //true默认根结点为展开,false不展开
rootnode.ImageUrl = " ";//这样应该行吧,不过不知道会不会显示一个X

[解决办法]
1,“+”号去掉
ShowPlusMinus属性设为False
2,单击问题
如果你的树结构已经是固定的话,只需要
Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand

RemoveHandler TreeView1.BeforeExpand, AddressOf TreeView1_BeforeExpand
e.Cancel = True
TreeView1.ExpandAll()

AddHandler TreeView1.BeforeExpand, AddressOf TreeView1_BeforeExpand

End Sub

[解决办法]
合拢的代码是:
Private Sub TreeView1_BeforeExpand(ByVal sender As Object, ByVal e As Private Sub TreeView1_BeforeCollapse(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewCancelEventArgs) Handles TreeView1.BeforeCollapse

RemoveHandler TreeView1.BeforeCollapse, AddressOf TreeView1_BeforeCollapse
e.Cancel = True
TreeView1.CollapseAll()

AddHandler TreeView1.BeforeCollapse, AddressOf TreeView1_BeforeCollapse

End Sub

热点排行