学习monodevelop并难以出现一个messgae框 [英] learning monodevelop and am having trouble getting a messgae box to appear

查看:139
本文介绍了学习monodevelop并难以出现一个messgae框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事monodevelop的工作,正在学习c#. 我试图显示一个消息框,但无法使其正常运行...

I am working in monodevelop and learning c#.... I am trying to get a message box to appear but I can't get it to function correctly ...

这是我的代码:

using System;  
using Gtk;  
using GtkSharp;  

public partial class MainWindow : Gtk.Window  
{
    public MainWindow () : base(Gtk.WindowType.Toplevel)  
    {  
        Build ();  
    }  

    protected void OnDeleteEvent (object sender, DeleteEventArgs a)
    {
        Application.Quit ();
        a.RetVal = true;
    }
    protected virtual void OnButton11ResizeChecked (object sender, System.EventArgs e)
    {
        System.Windows.Forms.MessageBox.Show("Hello World Again!!");
    }

}

我想念什么?

推荐答案

您不能混合使用GTK#和System.Windows.Forms UI工具包.您需要使用GTK对话框,如下所示:

You cannot mix the GTK# and System.Windows.Forms UI toolkits. You need to use a GTK dialog, something like this:

void ShowMessage (Window parent, string title, string message)
{
    Dialog dialog = null;
    try {
        dialog = new Dialog (title, parent,
            DialogFlags.DestroyWithParent | DialogFlags.Modal,
            ResponseType.Ok);
        dialog.VBox.Add (new Label (message));
        dialog.ShowAll ();

        dialog.Run ();
    } finally {
        if (dialog != null)
            dialog.Destroy ();
    }
}

另请参见此问题.

这篇关于学习monodevelop并难以出现一个messgae框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆