Question about Controls.Add in Class

Thread Starter

hunterage2000

Joined May 2, 2010
487
Hi all,

I am new to C# and have a problem.

I have a created a class called All_Buttons and have a method inside it called create_button1().

This method creates a button called b1. At the end of the method I have added Controls.Add(b1).

Inside the class, Controls.Add(b1) gives an error but having the same method outside of the class works fine.

Anyone know how to fix this?
 

Attachments

tribbles

Joined Jun 19, 2015
31
The nested class does not define a "Control" property, so it cannot be called.

The parent class /does/ define a "Control" property, so you could pass this into the nested class' function.
 
Top