Click here to Skip to main content
15,889,808 members
Articles / Desktop Programming / Windows Forms
Article

Simplifying GUI development with Actions

Rate me:
Please Sign up or sign in to vote.
3.08/5 (14 votes)
30 Jun 20051 min read 53.4K   1.2K   38   14
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


Written By
Web Developer
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
ambush_20008-Dec-10 15:39
ambush_20008-Dec-10 15:39 
GeneralApplication Settings [modified] Pin
sithiro10-Feb-07 5:59
sithiro10-Feb-07 5:59 
QuestionWhy not an Interface ? Pin
M.Genuini27-Dec-05 4:51
M.Genuini27-Dec-05 4:51 
AnswerRe: Why not an Interface ? Pin
Pestov1-Apr-06 23:33
Pestov1-Apr-06 23:33 
GeneralAnother ActionList on Code Project Pin
Peter Gummer21-Nov-05 15:34
Peter Gummer21-Nov-05 15:34 
GeneralRe: Another ActionList on Code Project Pin
Eric Engler28-Feb-06 6:48
Eric Engler28-Feb-06 6:48 
That other one is a more complete implementation, and it works on VS 2002, and includes icons and update events. However, there's some kind of bug in it that causes the VS 2003 form designer to remove Execute event handlers. I think the best solution might be to start with this one, and add some of the missing functionality to it.
General.NET 1.1 Version Pin
TylorDurden1-Jul-05 1:15
TylorDurden1-Jul-05 1:15 
GeneralRe: .NET 1.1 Version Pin
Burkovsky1-Jul-05 8:32
Burkovsky1-Jul-05 8:32 
GeneralRe: .NET 1.1 Version Pin
TylorDurden3-Jul-05 21:55
TylorDurden3-Jul-05 21:55 
GeneralRe: .NET 1.1 Version Pin
Burkovsky3-Jul-05 23:14
Burkovsky3-Jul-05 23:14 
Questionsomething like this can already be done? Pin
Bojan Rajkovic30-Jun-05 15:29
Bojan Rajkovic30-Jun-05 15:29 
AnswerRe: something like this can already be done? Pin
Burkovsky30-Jun-05 19:43
Burkovsky30-Jun-05 19:43 
GeneralRe: something like this can already be done? Pin
ambush_20008-Dec-10 15:42
ambush_20008-Dec-10 15:42 
AnswerRe: something like this can already be done? Pin
tonyt26-Jul-05 1:47
tonyt26-Jul-05 1:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.