private Menu CreateMenu(int depth, bool tearoff) { if (depth < 1) { return(null); } Menu menu = new Menu(); GLib.SList group = new GLib.SList(IntPtr.Zero); if (tearoff) { TearoffMenuItem menuitem = new TearoffMenuItem(); menu.Append(menuitem); } for (int i = 0, j = 1; i < 5; i++, j++) { RadioMenuItem menuitem = new RadioMenuItem(group, String.Format("item {0} - {1}", depth, j)); group = menuitem.Group; menu.Append(menuitem); if (i == 3) { menuitem.Sensitive = false; } menuitem.Submenu = CreateMenu((depth - 1), true); } return(menu); }
static Menu Create_Menu(int depth, bool tearoff) { if (depth < 1) { return(null); } Menu menu = new Menu(); MenuItem menuitem = null; string label = null; GLib.SList group = new GLib.SList(IntPtr.Zero); if (tearoff) { menuitem = new TearoffMenuItem(); menu.Append(menuitem); menuitem.Show(); } for (int i = 0, j = 1; i < 5; i++, j++) { label = String.Format("item {0} - {1}", depth, j); menuitem = new RadioMenuItem(group, label); group = ((RadioMenuItem)menuitem).Group; menuitem = new MenuItem(label); menu.Append(menuitem); if (i == 3) { menuitem.Sensitive = false; } Menu child = Create_Menu((depth - 1), true); if (child != null) { menuitem.Submenu = child; } } return(menu); }