InPowerS.Net

 找回密碼
 註冊
搜索
查看: 3786|回復: 0

C#中怎樣在兩個Form之間傳遞資料

[複製鏈接]
發表於 2008-12-29 16:30:57 | 顯示全部樓層 |閱讀模式

  1. public class Form1 : System.Windows.Forms.Form//兩個表單之1
  2. {

  3. static string OPC;//靜態變數用來保存

  4. public string xx

  5. {

  6. set{OPC=value;}


  7. get{return OPC;}

  8. }
  9. }
  10. public class Form2 : System.Windows.Forms.Form//兩個表單之2
  11. {

  12. Form1 form1=new Form1();

  13. form1.xx=要傳遞的值;
  14. }
  15. //這個時候當執行了Form2後,Form2的值就保存在Form1中的OPC裡。
複製代碼
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2025-4-11 21:03

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回復 返回頂部 返回列表