Well, i'd suggest to move data biding into
ucSignGen
. Imagine, you can easily set/get an object related with UserControl. All you need to do is to create custom property:
partial class ucSignGen
{
private SignalGenerator SigGen = new SignalGenerator();
public SingGenerator SignGenerator
{
get => SignGen;
set => SignGen = value;
}
}
Then in main form:
ucSignGen1.SignalGenerator = AnInstanceOfSignGen;
That's why you need to define an event - for example:
OnSignGen_Changed
in
ucSignGen
control.
public partial class ucSignGen : UserControl
{
public delegate void OnSignGen_Changed(object sender, EventArgs e);
private OnSignGen_Changed SignGenChanged;
public event OnSignGen_Changed SignGenChanged
{
add { SignGenChanged+= value; }
remove { SignGenChanged-= value; }
}
}
Please, read these articles to find out how to use events to communicate between forms:
Transferring information between two forms, Part 1: Parent to Child[
^]
Transferring information between two forms, Part 2: Child to Parent[
^]
Transferring information between two forms, Part 3: Child to Child[
^]
This should be helpful too:
Define an event in controls - Windows Forms .NET Framework | Microsoft Docs[
^]