C# Trying to call methods between classes created dynamically
I have been trying to work out how to call a method in a different class. Both classes are created dynamically at run-time. Most of the issues I have seen here relate to inheritance, which is different from what I have (I think.)

I am still fairly new to C#, and am trying to test some concepts out.

The first class is something like this:


    public class Record
    {
    CustomPanel _panel;
    
    public void recordFunc(){}
    }

The internally created class has something like this:

    public class CustomPanel : Panel
    {
    List<Control> _myControls = new List<Control>;
    // _myControls[0] += new EventHandler(myFunc);
    
    public void myFunc(object sender, EventArgs e)
    {
    // parentClass.recordFunc();
    }
    }


My objective is to create a Record at run-time from a database call. At that point, it creates a Panel (from my CustomPanel class) that gets added to a FlowLayoutControl. When events are fired from the panel's internal controls, I need to have it update parts of the parent Record class.

Any help is greatly appreciated.
Thanks,
Jim
C# Trying to call methods between classes created dynamically
===

I have been trying to work out how to call a method in a different class. Both classes are created dynamically at run-time. Most of the issues I have seen here relate to inheritance, which is different from what I have (I think.)

I am still fairly new to C#, and am trying to test some concepts out.

The first class is something like this:


    public class Record
    {
    CustomPanel _panel;
    
    public void recordFunc(){}
    }

The internally created class has something like this:

    public class CustomPanel : Panel
    {
    List<Control> _myControls = new List<Control>;
    // _myControls[0] += new EventHandler(myFunc);
    
    public void myFunc(object sender, EventArgs e)
    {
    // parentClass.recordFunc();
    }
    }


My objective is to create a Record at run-time from a database call. At that point, it creates a Panel (from my CustomPanel class) that gets added to a FlowLayoutControl. When events are fired from the panel's internal controls, I need to have it update parts of the parent Record class.

Any help is greatly appreciated.
Thanks,
Jim