Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Component not visible in propertygrid dropdown

Hello,

I hope somebody can help because I'm spinning my wheels and being driven insane by this remarkably odd problem...

I have two components that derive from System.Component, let's call them:
(a) componentHost
(b) componentEngine

componentHost was created in VS2003 (C#) using the "Add new Component" template. I merely added a single property called "Engine" which is of type "componentEngine". This property gets/sets a private field of the same type.

The componentEngine contains a property of type string. This component was created as described above.

FYI: These components are in different assemblies.

I open a new VSNET2003 and create a new winform project to test with. I then add my 2 assemblies (containing both components) to the VSNET2003 toolbox. I then drag-n-drop one instance of each control onto the form.

When I click on the componentHost.Engine property, the dropdown (provided by VS) shows me componentEngine - exactly what I want...

This is where the "fun" begins...

Now, I derive from componentEngine to create a component called ComponentEngineTypeA. This derived engine does nothing more than derive from the class. Period.

I now go back to VS and start with a new project. I do the exact same steps as before, but this time I add the componentHost and the componentEngineTypeA components.

If I click on componentHost and click on the "Engine" property, VS provides a dropdown that "should" show me what engines are available to pick. This is the problem, it doesn't. Instead, I see a blank drop-down. :confused:

Furthermore, if I delete componentHost, and then add it back onto the form, then the "Engine" property (dropdown) does then show the componentEngine. :confused:

Here's some source code:

//this is the host, that contains the property we want to see visual studio
//provide a drop-down for... that will display a list of
//componentEngine types that exist on the form.
public class componentHost : Component{
Container components=null;

public componentHost(IContainer parent){
parent.Add(this);
initializeComponent();}

public componentHost(){ initializeComponent(); }

void initializeComponent(){components=new Container();}

componentEngine engine;
public componentEngine Engine{
get{ return(engine); }
set{ engine=value; } }
}

//this is a base class that our component above contains a property for
public class componentEngine{
Container components=null;

public componentEngine(IContainer parent){
parent.Add(this);
initializeComponent();}

public componentEngine(){ initializeComponent(); }

void initializeComponent(){components=new Container();}

string someString;
public string SomeString{get{return(someString);}set{someString=value;}}
}

//this is a derived class
public class componentEngineTypeA : componentEngine{}

If anybody has any ideas then please let me know.. I've spent literally days on this and I'm no further ahead. Thank you.
[3241 byte] By [npocock] at [2007-11-11 8:13:38]