我想实现的功能是遇到异常时弹出错误提示对话框:窗口中显示三个按钮【确定】【取消】【详情】
点击详情在错误窗口中显示错误的详细信息....
在Winform中如何实现?

解决方案 »

  1.   

    MessageBox.Show("客户不能为空!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
      

  2.   

    MessageBoxButtons后面可以自己选择
      

  3.   

    直接用 MessageBox.Show 只能有系统定义的一些按钮,(MessageBoxButtons.YesNoCancel等)
    如果要显示三个按钮【确定】【取消】【详情】 自己写个Form 就是了.
      

  4.   

    自己写Form实现。
      

  5.   

    简单点,自己写个Form,放三个按钮上去就行了复杂点,设置WH_CBT钩子,对MessageBox的WndProc自己处理
      

  6.   

    【确定】【取消】【详情】????
    那用MessageBox.Show()还无法实现,
    还是再写个form页面吧
      

  7.   

    继承 MessageBox 类改个Button的Text
      

  8.   

    两种方式,简单的可以通过MessageBox类来实现,
    如果需要更灵活的控制建议楼主自己写一个Form窗体继承类进行解决。另外给楼主一个扑获全局异常事件的代码例子。=====================================
    使用全局事件扑捉
    =====================================
    using System;
    using System.Windows.Forms;
    //using Microsoft.Win32;//注册全局的异常处理程序,扑获产生的异常。
    namespace Zhengzuo.CSharpCode
    {
        static class Program
        {
           
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            { 
                if ( false == SingleInstance.HandleRunningInstance() )
                {
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                    //SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);                Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new FormMain());
                }
            }        //static void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)
            //{
            //    throw new Exception("The method or operation is not implemented.");
            //}        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
            {
                throw new Exception("The method or operation is not implemented.");
            }        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }
    }
      

  9.   

    微软自带的MessageBox,没有你说的那个扩展功能,可以自己写,使用一个对话框即可