我正在开发Outlook 2010的加载项。
基本上,我的功能区上有一个按钮,它将选定的电子邮件并将其保存到文本文件中。如果电子邮件包含某个主题,则保存将自动完成到硬编码的文件路径。如果没有,则打开一个窗体窗体,要求用户输入文件路径。Windows窗体将无法正常关闭
当用户选择了一个路径,并点击'确定'保存发生,然后窗体关闭...但它然后重新打开...它似乎是创建一个新的实例或东西...如果我点击'取消'或'X'关闭,但我不明白为什么它第一次没有正确关闭。
下面是我的代码
//This is myRibbon.cs
private void btn_SaveFile_Click(object sender, RibbonControlEventArgs e)
{
//other code
if (subject = "xyz")
{
//other code
textFile.Save();
}
else
{
MyPopup popup = new MyPopup();
popup.ShowDialog();
}
}
//This is MyPopup.cs
private void btnOK_Click(object sender, EventArgs e)
{
var filePath = txtFilePath.Text;
if (!string.IsNullOrWhiteSpace(filePath))
{
SaveEmailToText(filePath);
this.Close();
}
else
{ //show message box with error }
this.Close();
}
private static void SaveEmailToText(string filePath)
{
//other code
textFile.Save();
}
我简化了这个颇有几分所以它更容易阅读。 任何帮助将不胜感激。
您需要关闭或处置通过检查DialogModalResult ..是什么似乎缺少的形式,你可以显示MyPopup如何被声明..?它不在表格上Initialize是..? – MethodMan