0

I am new to using Windows forms and am looking for help on creating a Tree Node Menu Structure in Windows Forms. I have tried reading the documentation on Microsoft docs and testing out the examples still with no clear understanding of how to create a tree node menu structure. Any help would be greatly appreciated as I am just learning Windows Forms.

Here is an example of how I would like the structure (the menu items should be tabs):

Node: Customers

-Child node: Add Customers

-Child Node: Add Customer Part

  • You do know that you can add a Menu to the form. It doesn't have to be docked. https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.menustrip?view=netframework-4.8 – dbasnett Apr 08 '22 at 18:49
  • Oh okay, Any idea how I would create a class that holds the main context and contains the sub context per main context? – user1177119 Apr 08 '22 at 19:25

1 Answers1

1

Not 100% sure if this is what you are looking for, but basically define your context menu (assuming a right click here)

nodeMenu As ContextMenuStrip

Build your items and a menu handler, then when your node is selected, define which items of the menu will be available along these lines:

if node.Text.Equals("Customers") then
    nodeMenu.Items("Add Customers").Enabled = True
    nodeMenu.Items("Add Customer Part").Enabled = True
Else 
   'do something else
End If

but that is to add a menu to a node.

I think what you want is add nodes under a specfic node, if that is the case, I believe what you are after is more likely the answer here: https://stackoverflow.com/a/9963900/1946036