[Gtk-sharp-list] Add MenuItem

innominate natenate at gmail.com
Thu Aug 21 19:33:58 EDT 2008


Thanks that worked.  Only other thing was I had to do .Show() on the MenuItem
and .ShowAll() on the Menu.
Another odd thing: In the code generated by the MonoDevelop gui designer it
is creating Actions and  ActionsGroups instead of menu items.  Then I guess
generating the entire MenuBar using the ActionGroups and Actions.  Why are
there two different ways to do it?, and are there advantage/disadvantages to
the differnt ways?

Thanks
Nate


Adam Tauno Williams-2 wrote:
> 
>> 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.
> 
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
> 
> 

-- 
View this message in context: http://www.nabble.com/Add-MenuItem-tp19023962p19098962.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list