iro*_*s7x 2 c# linux gtk# monodevelop
我正在monodevelop和学习c#....我试图让消息框出现,但我无法让它正常运行...
这是我的代码:
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!!");
}
}
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
Mik*_*son 12
您不能混合使用GTK#和System.Windows.Forms UI工具包.您需要使用GTK对话框,如下所示:
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 ();
}
}
Run Code Online (Sandbox Code Playgroud)
另见这个问题.
| 归档时间: |
|
| 查看次数: |
7273 次 |
| 最近记录: |