Вопрос

I have 2 form in Mono.In OnClickEvent of a button in Form1, i want to showDialog Form2 and fetch a answer from Form2.In C# i have this code

Form2 F=new Form2();
F.ShowDialog();
int MyAnswer=F.Answer;

But in Mono ShowDialog() function does not exist.

this question mean: i want to show Form2 but Form1 wait for result of Form2

Это было полезно?

Решение

Instead of using Gtk.Window you can use Gtk.Dialog and use this code.

ResponseType response = ResponseType.None;
using (var dlg = new YesNoDialog ("Title", "Question", "Yes Button", "No Button"))
    response = (ResponseType) dialog.Run ();

if (response == ResponseType.Yes)
        OverwriteFile ();

Другие советы

It looks like you are trying to use System.Windows.Forms.Form.ShowDialog() in a Gtk# application.

The equivalent Gtk# function is called Gtk.Dialog.Run, see Is there a Form.Showdialog equivalent for Gtk# Windows?

You also need to create a Dialog, not a Form - ie. when you add the new class in MonoDevelop, you choose "Gtk / Dialog", not "Gtk / Widget".

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top