Windows Develop Bookmark and Share   
 index > Windows Forms General > Problem with System.ComponentModel.Component
 

Problem with System.ComponentModel.Component

hi,

I want to create two classes that derive from System.ComponentModel.Component.

ClassA will be my container.

ClassB will be the class that will be stored in a collection variable inClassA.

When the developer drags and drops an instance of ClassB into the ClassA Design View, I want to add this ClassB instance to the ClassB collection on ClassA.

Here's my code:

public classClassA : Component

{

List<ClassB> classBList = new List<ClassB>();

}

// I'll dragfrom toolboxinstances of this class and drag them into ClassA Design View

public classClassB : Component

{

}

thanks in advance.

Auad  Monday, October 29, 2007 11:16 AM

Th solution was very simple....

I just added a property to ClassB which has a reference to its container class (ClassA).

public ClassA ContainerClass

{

get { return classA; }

set

{

classA= value;

classA.classBList.Add(this);

}

}

thanks anyway

Auad  Tuesday, October 30, 2007 11:57 AM

Th solution was very simple....

I just added a property to ClassB which has a reference to its container class (ClassA).

public ClassA ContainerClass

{

get { return classA; }

set

{

classA= value;

classA.classBList.Add(this);

}

}

thanks anyway

Auad  Tuesday, October 30, 2007 11:57 AM

You can use google to search for other answers

Custom Search

More Threads

• Cursor and Threading
• FXcop
• Cross-thread operation not valid with splashscreen
• Control.BringToFront() triggering MouseMove
• Easiest way determine when outside a control was clicked?
• Simple Question connecting two input fields...
• Style Sheet MSHTML Editor
• Recompiling COM Wrapper
• A date Question
• System Out OF Memory Exception