Click here to Skip to main content
15,513,354 members
Articles / Desktop Programming / Windows Forms
Article
Posted 30 Jun 2005

Stats

52K views
1.2K downloads
38 bookmarked

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
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 16:39
ambush_20008-Dec-10 16:39 
GeneralApplication Settings [modified] Pin
sithiro10-Feb-07 6:59
sithiro10-Feb-07 6:59 
QuestionWhy not an Interface ? Pin
M.Genuini27-Dec-05 5:51
M.Genuini27-Dec-05 5:51 
AnswerRe: Why not an Interface ? Pin
Pestov2-Apr-06 0:33
Pestov2-Apr-06 0:33 
GeneralAnother ActionList on Code Project Pin
Peter Gummer21-Nov-05 16:34
Peter Gummer21-Nov-05 16:34 
GeneralRe: Another ActionList on Code Project Pin
Eric Engler28-Feb-06 7:48
Eric Engler28-Feb-06 7:48 
General.NET 1.1 Version Pin
TylorDurden1-Jul-05 2:15
TylorDurden1-Jul-05 2:15 
GeneralRe: .NET 1.1 Version Pin
Burkovsky1-Jul-05 9:32
Burkovsky1-Jul-05 9:32 
GeneralRe: .NET 1.1 Version Pin
TylorDurden3-Jul-05 22:55
TylorDurden3-Jul-05 22:55 
GeneralRe: .NET 1.1 Version Pin
Burkovsky4-Jul-05 0:14
Burkovsky4-Jul-05 0:14 
Questionsomething like this can already be done? Pin
Bojan Rajkovic30-Jun-05 16:29
Bojan Rajkovic30-Jun-05 16:29 
AnswerRe: something like this can already be done? Pin
Burkovsky30-Jun-05 20:43
Burkovsky30-Jun-05 20:43 
GeneralRe: something like this can already be done? Pin
ambush_20008-Dec-10 16:42
ambush_20008-Dec-10 16:42 
AnswerRe: something like this can already be done? Pin
tonyt26-Jul-05 2:47
tonyt26-Jul-05 2: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.