C# winform: Accessing public properties from other forms & difference between static and public properties

前端 未结 5 718
说谎
说谎 2020-12-03 18:54

I am trying to understand whats the difference between a static and public properties. But when I tried to access my public property \'Test\' in other form it says \'null\'.

5条回答
  •  我在风中等你
    2020-12-03 19:41

    Use of this method 'static'

    At first Control label property Modifiers=Public

    in Program code below

    public static Form1 frm1 = new Form1();
    public static Form2 frm2 = new Form2();
    

    in Form1 code below

    Program.frm2.show();
    

    in Form2 code below

    label1.Text=Program.frm1.text; 
    

提交回复
热议问题