選擇選項,我遇到一個問題,而選擇在我的MessageBox 是的按鈕是或沒有。一個錯誤,同時從DialogResult的
Object reference not set to an instance of an object.
從行:
AddEntryWindow addWindow = new AddEntryWindow
(this, storedAuth.UserName, storedAuth.Password);
我不明白有什麼問題,因爲在此之後幾行字,是相同的語句。我怎樣才能解決這個問題?
固定
private void tsmiAddEntry_Click(object sender, EventArgs e)
{
if (storedAuth == null)
{
DialogResult result = MessageBox.Show
("You must log in before you add an entry."
+ Environment.NewLine + "You want to authenticate?",
"Information", MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
AuthenticationWindow authWindow =
new AuthenticationWindow();
authWindow.ShowDialog();
storedAuth = authWindow.Result;
AddEntryWindow addWindow = new AddEntryWindow
(this, storedAuth.UserName, storedAuth.Password);
addWindow.ShowDialog();
}
}
else
{
AddEntryWindow addWindow = new AddEntryWindow
(this, storedAuth.UserName, storedAuth.Password);
addWindow.ShowDialog();
}
}
Jeez,你說得對。我誤解了我自己的問題。我想打開註冊窗口。 – HelpNeeder
...在addentry窗口之前。 – HelpNeeder