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:
- Install the
ActionListProvider
into VS.NET.
- Add an
ActionListProvider
on the form.
- Add some new actions, through
ActionListProvider
's Action
property.
- Define the
Action
's Execute
event handler.
- Add some Buttons.
- Link them with
Action
s.
- 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.