How to change a label from another class? c# windows forms visual studio

后端 未结 4 726
旧巷少年郎
旧巷少年郎 2021-01-28 01:25

I know there are a lot of threads talking about this and believe me I\'ve seen all of them, but I think I\'m a little slow and cant figure out how to do this so here is the thin

4条回答
  •  庸人自扰
    2021-01-28 01:50

    Simply change your label' s Modifier prperty to internal or public and then call your form and change your label text directly..

    i.e.

    Form2 frm = new Form2(); // Form 2 contains label8 and calling in a method (i.e.buttonclick) of form1
    
    if (List.Count > 0)
    {
       frm.Label8.Text = "Someone Loves Me :)";
    }
    else
    {
       frm.Label8.Text = "Noone Loves Me :(";
    }
    

提交回复
热议问题