InfoPath表单上未显示MessageBOX

本文关键字:显示 MessageBOX 表单 InfoPath | 更新日期: 2023-09-27 18:29:28

当视图在窗体上切换但屏幕显示为空白时,是否应显示消息框?我不知道为什么。我尝试添加对Windows.Forms以及的引用

 using Microsoft.Office.InfoPath;
 using System;
 using System.Xml;
 using System.Windows.Forms;
 using System.Xml.XPath;
namespace Form1
{
    public partial class FormCode
    {
      public void InternalStartup()
      {
      }
      public static DialogResult FormEvents_ViewSwitched(object sender, ViewSwitchedEventArgs e)
      {
        string string1 = "Error";
        string string2 = "Empty field found on form";
        // Set button of type "MessageBoxButton" 
        MessageBoxButtons button = MessageBoxButtons.YesNo;
        // Static method, referenced without an object but just using the class 
        return (MessageBox.Show(string1, string2, button));
      }
    }
}

InfoPath表单上未显示MessageBOX

您应该使用以下

MessageBox.Show("Display Error Message Text Here", "Title that appears on MessageBox here", MessageBoxButtons.YesNo);

也谷歌如何使用字符串。格式或字符串。联接或字符串。Concat for your message