![](/img/trans.png)
[英]VB.NET 2019 How to populate a Tag Property on a dynamic ToolstripmenuItem
[英]How add ToolStripMenuitem in Treeview using VB.NET 2005
我有如下的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
現在我想按如下順序將其添加到樹視圖中
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.