Static properties on design-time

A couple of weeks ago I was working on a component to use & generate html help files. The idea was to drop a component on each form where it would do it’s work:

  1. Generate files for Microsoft’s HtmlHelp Workshop when executed from Visual Studio.
  2. Show all kind of context sensitive help when executed outside Visual Studio.

During the writing I needed an Enable property visible in the property inspector of Visual Studio that was global to all instances of my component.

I used the following (simple) construct:

   1:  

   2: public Boolean Enabled {

   3:   get { 

   4:     return fEnabled; 

   5:   }

   6:   set { 

   7:     fEnabled = value; 

   8:   }

   9: }

  10:  

  11: private static fEnabled = true;

  12:  

This code shows a Enabled property in the property inspector, but when the value is of a single component instance is changed, the changed value in all other instances too.

Advertisements
This entry was posted in C#, Programming. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s