2010-08-04 38 views
1

在Windows Mobile 6.1教授。Windows移動消息框this.close()?

我有一個消息框,它是一個是/否按鈕。當我點擊消息框中的「否」選項時,我的整個應用程序關閉,如何關閉消息框?

   string message = "Application will perform a data download agree?"; 
       string caption = ""; 
       MessageBoxButtons buttons = MessageBoxButtons.YesNo; 
       DialogResult result = MessageBox.Show(message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); 

       if (result == DialogResult.Yes) 
       { 

        navigateForward(WEB_PAGE_NAVIGATE); 

       } 

       else 
       { 

        this.Close(); 

       } 

回答

3

您不需要關閉消息框。這是一個DialogWindow,當你點擊任何一個選項將關閉本身。

DialogResult result = MessageBox.Show(); 
if (result == DialogResult.Yes) 
{ 
    navigateForward(WEB_PAGE_NAVIGATE); 
} 
else 
{ 
    // No need to do anything here as the MessageBox is closed automatically. 
} 

你的整個應用程序關閉的原因是因爲this涉及類你目前是我猜類的主要是Form,當你的主窗體關閉時,應用程序關閉。