- public class Form1 : System.Windows.Forms.Form//兩個表單之1
- {
- static string OPC;//靜態變數用來保存
- public string xx
- {
- set{OPC=value;}
- get{return OPC;}
- }
- }
- public class Form2 : System.Windows.Forms.Form//兩個表單之2
- {
- Form1 form1=new Form1();
- form1.xx=要傳遞的值;
- }
- //這個時候當執行了Form2後,Form2的值就保存在Form1中的OPC裡。
複製代碼 |