How can I manage toolbars, menus, and context sensitive items?

I am currently developing a WinForms application in C # and need some input on how to control toolbar buttons, menus, and other context sensitive items. What is the best practice for this?

I found the article Use Design Patterns to Simplify the Relationship Between Menus and Form Elements in .NET 'on MSDN, but I'm not sure if there is a better way, because the article is quite old (it was published in 2002).

I am grateful for any constructive help.

+4
source share
3 answers

When developing an application that uses events intensively (many menus, toolbars in many forms), certain events usually overlap or repeat in the sense that there are many ways to do something specific, and I see this redundancy as a benefit to the user, but a curse for the developer.

A well-planned, object-oriented approach will determine how to manage events triggered by events to avoid duplication or overlap of code.

+1
source

You could, of course, find a very useful source of inspiration in Microsoft Office, as it is somewhere standard (standard?).

Depending on the type of form you are using, I assume that you can set some basic rules where, for example, the data entry forms will have a basic menu, such as validate \ quit \ refresh \ abandon \ print \ export, to excel \ filter \ order by \ etc. Such menus (let them be called " Standard ") will be ideally accessible in the "File" and "Edit" and / or "View" menus, adhering to standard Office menus (even Firefox uses this terminology).

I would advise you to always display this standard menu, even if some of these actions are not always available for such or similar forms. Imagine that the data contained in one of your forms cannot be updated under certain circumstances: you can still display the disabled version of the "validate" icon, and not make it invisible. This will definitely simplify the understanding of the end user.

Once this standard list of menus / options is installed, I think you will come to the identification of the other two main "menus", " More " and " Actions " menus:

  • Parts allow you to navigate through forms, access / display subforms / subsets of data, such as Items in a purchase order.
  • The action allows you to perform certain actions on the data, for example, to issue a purchase order.

Your various menus should be accessible through the command bar and context-sensitive shortcuts. Parameters such as “filter” may be available at the associated control level, while actions such as “Emit PO” are available only at the record / form level.

People or a group of people should be allowed or not to open forms and / or perform certain actions in these forms

To manage menus and rights, our applications have a “menu file” by default on the client side and both tables “userGroup-forms” and “userGroup-actions” on the server side.

  • user group groups . and forms and watchlist \ change permissions of each group. Table
  • userGroup-actions holds true when the group has the right to perform a specific action

When connected to the database, the user is identified, and his local menu file is updated to give him the appropriate viewing / action rights.

We are clearly here in an object-oriented approach, right?

0
source

The ToolStripManager class has a merge method, so you can have any child forms / user controls by exposing your own ToolStrips that combine with your main form toolbar when they have focus.

http://msdn.microsoft.com/en-us/library/5523fet0.aspx

If you use MDI, you can also combine the menu items of the parent and child forms.

http://msdn.microsoft.com/en-us/library/ms404319%28VS.80%29.aspx

0
source

All Articles