I have created a Table layout in windows forms as shown in figure, i have added a right mouse button click Menu to my table,
i wnt to add submenu items to following menuitems such as
When i click add device
it should show subitems such as sounder
, MCP
, strobe
etc
When i click fault
it should show subitems such as open circuit fault
, sounder fault
, `short circuit fault' so on
This is how i created menuitems
ContextMenu m = new ContextMenu();
MenuItem addDevice = new MenuItem("Add Device");
MenuItem deleteDevice = new MenuItem("delete Device");
MenuItem fire = new MenuItem("Fire");
MenuItem fault = new MenuItem("Fault");
MenuItem suppress = new MenuItem("Suppress");
m.MenuItems.AddRange(new MenuItem[] { addDevice, deleteDevice, fire, fault,suppress});
tableLayout.ContextMenu = m;
m.Show((Control)(sender), e.Location);
The below is my form and table layout
You can add MenuItems
to existing MenuItem
like:
MenuItem addDevice = new MenuItem("Add Device");
addDevice.MenuItems.Add( new MenuItem("Add More .."));
It would be visible like:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With