2012-10-20 55 views
0

我Toolstripmenuitem如下,如何在樹視圖使用VB.NET 2005

enter image description here

使用下面的代碼我正在歌廳結果像添加ToolStripMenuitem,

For Each t As ToolStripItem In fobj.MenuStrip1.Items 
     Dim parentnode As TreeNode = TreeView1.Nodes.Add(t.Name, t.Name) 
     GetMenues(t, menues, parentnode, 1) 
     parentnode.Expand() 
Next 

Public Sub GetMenues(ByVal Current As ToolStripItem, ByRef menues As List(Of ToolStripItem), ByVal parentnode As TreeNode, ByVal s As Integer) 
    If Not String.Compare(s.ToString, "1") = 0 Then 
     Dim fatherNode As TreeNode = parentnode.Nodes.Add(Current.Name, Current.Name) 
    End If 
    If TypeOf (Current) Is ToolStripMenuItem Then 
     For Each menu As ToolStripItem In DirectCast(Current, ToolStripMenuItem).DropDownItems 
      GetMenues(menu, menues, parentnode, s + 1) 
     Next 
    End If 
End Sub 

enter image description here

現在我想添加到樹形視圖像下面的順序

enter image description here

感謝

回答

0

Finaly我得到了解決這個問題,

Please Refer this Link

該規範是解決了這個問題與小的修改。

謝謝