Invoke function of parent Panel

Hello,

I have just started programming in C++ so please forgive me in advane...
So here is the thing:
I have a class A inherited from Panel and there is a button on it:

1
2
3
4
public ref class aClass: System::Windows::Forms::Panel
{
System::Windows::Forms::Button^  aButton = gcnew System::Windows::Forms::Button();
};


And there is a class B which has a list of class A and is from Panel as well:

1
2
3
4
5
public ref class bClass: System::Windows::Forms::Panel
{
void fn();
System::Collections::Generic::List<aClass^>^ aClasses;
}


I create an instance of class B and fill up the list inside with instances of A.
So far so good.
What I would like to do is to invoke function fn() of instance B Panel when the buttons in A are pressed.

Any help is much appreciated



EDIT:

I found out the following solution (I do not know whether it is the most elegant way):

When inserting the new instance of class A I add an event handler to its button which is implemented in B this way current situation is solved.

But what if I want to invoke a function without triggering an event... ?

EDIT:

I found the solution: using delegates(like a conventional function pointer) solves the problem
Last edited on
Topic archived. No new replies allowed.