我有一個自定義窗體將值返回給主窗體,但它沒有看到變量。我認爲我沒有把這個說得很清楚,所以我將包含我想要做的事例的鏈接。我的對話框返回值不起作用
我知道我可能忽視的東西很容易,或者明顯的,但這裏是我。
Form1.cs中:
private void addTime_Click(object sender, EventArgs e)
{
Form add = new addTime(false, new string[] { "", "" });
if (add.ShowDialog(this) == DialogResult.OK)
{
// the line not working
Label1.Text = add.Details;
// reports with:'System.Windows.Forms.Form' does not contain a
// definition for 'Details' and no extension method 'Details' accepting
// a first argument of type 'System.Windows.Forms.Form' could be found (are you
// missing a using directive or an assembly reference?)
}
}
addTime.cs:
internal class addTime : Form
{
//..
private string _details;
public string Details
{
get { return _details; }
private set { _details = value; }
}
private string _goalTime;
public string GoalTime
{
get { return _goalTime; }
private set { _goalTime = value; }
}
private void applybtn_Click(object sender, EventArgs e)
{
Details = detailslbl.Text;
GoalTime = goalTimelbl.Text;
}
}
哇!我知道它必須是簡單的!哈哈,謝謝,雖然我現在覺得自己像個白癡。 – Nyight 2009-08-18 17:56:50
好的,我錯過了 – 2009-08-18 18:00:15