看板 C_Sharp 關於我們 聯絡資訊
我用以下的方法解決了第一跟第二個問題(解決第二個問題的地方標黃色) : 推 chentsungmin:直接覆寫 Form1.New(String val), 或是在Form1 宣告 07/22 : → chentsungmin:一個Public String變數,在Form1 new之後直接以 07/22 : → chentsungmin:Form1.XXX存取變數也可以..方法很多種囉 07/22 Program.cs 的部份 Form1 表單部份 static void Main() string user = ""; { Login flogin = new Login(); public Form1(String name) string name = ""; { InitializeComponent(); flogin.ShowDialog(); this.user = name; } if (flogin.Visible == false) name = flogin.name; if (flogin.result == DialogResult.OK) Application.Run(new Form1(name)); flogin.Dispose(); } Login 表單部份 // 程式前端有宣告 public string name; if (驗證成功) { // 前略…… this.name = ……; this.Hide(); this.DialogResult = MessageBox.Show(…); } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.59.78.243