Pass data from one form to another class [closed]

2

I have a very cute form1 with very good button and inside it I have a toggle button on-off. I have another class.cs and I have a condition in it, but will only execute if that button there on form1 is on. follows in Form1.cs:

        private void metroToggle1_CheckedChanged(object sender, EventArgs e)
    {
        // caso ligado retorna true ou false algo do tipo
    }

My other class.cs

    if(form1.botao = true ou retorna 0 ou 1){

             // faz alguma coisa
     }

I hope you have understood my question I am a beginner in C # seems simple to those who have more experience for me ta bone = /. Thanks in advance for the help.

    
asked by anonymous 23.11.2016 / 17:31

1 answer

3

Cesar, if I understand, you want it when you change your checkbox and it is checked, it executes an action.

You can do this:

private void metroToggle1_CheckedChanged(object sender, EventArgs e)
{
    if (metroToggle1.Checked)
    {
        Classe.Executar();
    }
}

Within your class you will have a method called Run

public static void Executar()
{
    /// faz alguma coisa
}
    
23.11.2016 / 19:00