Creating Event for Multiple Forms

Total Post:70


 1225  View(s)
Rate this:

I have tried a bunch of different things, so obviously I am now stuck... I have created a form, it has a button on it - that when clicked creates a new form. I can click away and create multiple forms this way. What I would like and cannot get to work is to have the main form have a second button on it - that when clicked will change all of the background colors on the secondary forms.

  1. Re: Creating Event for Multiple Forms

    Hi Samuel,

    In your parent form do something like this.

    private event Action<Color> ChangeColor;
    private void CreateAndShowForm()
        var form2 = new Form2();
        ChangeColor +=form2.changeColor;
        /*do other stuff to show form*/
    private void button1_Click(object sender, EventArgs e)
    In the child forms
    public void changeColor(Color obj)
        /*change background color*/

      Modified On Apr-04-2018 03:38:53 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.