We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Adding Menu Items in code

Hi There, I'm trying to add menu to my main form and am having no luck! Seems like I'm missing a step, but what? int catId = mainMenuManager.Categories.Add("xxxx"); ParentBarItem menuBar = new ParentBarItem(); menuBar.CategoryIndex = catId; menuBar.ID = "zzzz"; menuBar.Text = "test"; mainMenuManager.Items.Add(menuBar); mainMenu.Items.Add(menuBar);

1 Reply

RP Ramesh Praveen Syncfusion Team June 16, 2003 10:23 AM UTC

Hi, A ParentBarItem represents a dropdown submenu (please refer to our User's Guide in Tools\Docs\User's Guide folder) which itself needs to be added to a Bar instance. So, you will have to also do this: Bar mainMenuBar = new Bar(); mainMenuBar.BarStyle = BarStyle.IsMainMenu|...; mainMenuBar.Text = '..."; // This will add an empty main menu bar to your form mainMenuManager.Bars.Add(mainMenuBar); // Then create a new instance of a ParentBarItem as in the code above and add it to your mainMenuBar. mainMenuBar.Items.Add(parentBarItem); Regards, Praveen

Live Chat Icon For mobile
Up arrow icon