Sunday, January 31, 2010

.Net menu

Define context menu.

The menu that you get when you right-click is called the context ment. It is a modular piece of markup code that can move around the page. It consists of two distinct blocks—the user interface and the script code to connect the UI to it. 

What is the purpose of CloneMenu?

CloneMenu method copies the whole list of MenuItem objects into the current menu. It accepts a parameter of the type Menu. It can be used in a derived class to clone MenuItem objects. They can then be reused by other classes that derive from Menu.  

Explain how to dynamically add items to a menu in .NET.
Following answer provides a very generalized idea of how this can be done:
  • The first step would be locating the Assembly DLL.
  • An appropriate plug-in can be indicated by publishing an interface residing in the remote DLL. This is the second step.
  • Then, load the DLL using the LoadFrom method.
  • Validate plug-in status using reflections.
  • Create a new instance of the object in the class supporting your interface.
  • Then use the GetMenuItem method to have the class to return a MenuItem object.
  • And then add the MenuItem.

Explain how to dynamically clone a menu in .NET.

Follow the steps below to dynamically clone a menu in .NET:

  • Create an alternate MainMenu object.
  • Clone the first menu with the CloneMenu method.
  • Create additional menu items related to the application state.
  • Then add the new menu items to the MenuItems collection of the top-level menu item cloned. This can be done by using the Add method to specify their order within the collection by their index.
Assign the newly-created MainMenu object to the form

0 Comments: