[Gtk-sharp-list] Add MenuItem
Adam Tauno Williams
adam at morrison-ind.com
Thu Aug 21 16:51:33 EDT 2008
> Hi I am a first time gtk# user. I am looking for an equivalent way to do
> this in gtk#:
> MenuItem m2 = new MenuItem("bla");
> m1.MenuItems.Add(m2);
> In other words dynamically add or remove menu items. Right now I am using
> the gui editor with monodevelop to generate my gui code, and from the code
> it generates the only way I can see would be to regenerate the entire menu.
If you have a Menu I believe you can use Attach(...) to add a new
MenuItem.
There is an example in Monodoc:
MenuBar mb = new MenuBar ();
Menu file_menu = new Menu ();
MenuItem exit_item = new MenuItem("Exit");
file_menu.Append (exit_item);
MenuItem file_item = new MenuItem("File");
file_item.Submenu = file_menu;
mb.Append (file_item);
The Activated event is emitted from a MenuItem when it is activated.
More information about the Gtk-sharp-list
mailing list