Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Simplifying GUI development with Actions

0.00/5 (No votes)
30 Jun 2005 1  
Simplifying GUI development with Actions.

Introduction

Are you a Delphi developer? If so, then you probably miss the useful ActionList component. I decided to code some component that mimics the Delphi component behavior. What's ActionList? It is a collection of actions, which could customize the look and behavior of some GUI elements. For example, an action can define the text shown on a button and the action which this button fires. The advantage of action is that you can use the same action with several components e.g. Print toolbar button and menu item, and you need to define the action (event) only once. You can also centrally enable or disable all the GUI components associated with the action.

How I implemented it?

The ActionList is implemented as an IExtenderProvider (ActionListProvider), which adds to ButtonBase and ToolStripItem successors a new Action property to define the actions. The Action has two properties Enabled and Text. Both will set the same properties of the linked control. There is an event Execute which is fired through the Click event of the control.

Using the ActionListProvider

Using the ActionListProvider is very easy. Follow these steps:

  1. Install the ActionListProvider into VS.NET.
  2. Add an ActionListProvider on the form.
  3. Add some new actions, through ActionListProvider's Action property.
  4. Define the Action's Execute event handler.
  5. Add some Buttons.
  6. Link them with Actions.
  7. Now you can centrally enable and disable all the controls associated with this Action.

Points of interest

The code is written in .NET 2.0 and can be extended according to your needs.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here