How do I set control properties between winforms

Hi,

I'm using properties and overloaded contructors for pass data between winforms, and it works very well, however, I can’t set some properties for windows controls, for example, I'm trying to set the label.Text property that it's located in a Winform called "frmPlanificador", from another Winform called "frmActividades", but it doesn’t work yet.

This is that I'm trying to do :
**********************************************************************************************************
formPlanificador.PKActividad = pkActividad;
formPlanificador.lblActividad.Text  =                      ObjEncryptDecrypt.Decrypt(ObjActividad.NombreActividad.Valor.ToString());
formPlanificador.enableComponents(true);
**********************************************************************************************************
I'm executing that code from another form, the "PKActividad" property works fine, but "formPlanificador.lblActividad.Text" always is blank...

 Thanks in advance



Answer this question

How do I set control properties between winforms

  • ironhead.chuang

    Thanks,

    In fact, I tried this: "formPlanificador.lblActividad.Text  = "Hello World"; but it doesn't work either.
    The sentence: "ObjEncryptDecrypt.Decrypt(ObjActividad.NombreActividad.Valor.ToString())"  returns a good string, I think that isn’t the problem.

    I declare tho object here:
    SAVP.Planificador.frmPlanificador formPlanificador;

    After that, I create the the object:
    formPlanificador = new SAVP.Planificador.frmPlanificador();

    Then, in the Click Event:
    private void btnSeleccionar_Click(object sender, System.EventArgs e)
    {
        formPlanificador.PKActividad = pkActividad;
        formPlanificador.lblActividad.Text = ObjEncryptDecrypt.Decrypt(ObjActividad.NombreActividad.Valor.ToString());
        formPlanificador.enableComponents(true);
        this.Close();
    }

    and that's it...

    I don’t know what is going on


  • bpell

    I did a very simple test of one form changing the value of a label in an other form and it work. I think your problem is not in this part the the code.

    Is

    ObjEncryptDecrypt.Decrypt(ObjActividad.NombreActividad.Valor.ToString());

    return a good string

    Are you changing the right label, do you have a good reference to your form

  • Nazar Ali

    So in frmActividades you actually create a new instance of formPlanificador You should pass it as a parameter or in the constructor of frmActividades.



  • Srikanth Anumalla

    Right, thanks a lot!


  • How do I set control properties between winforms