Search code examples
monogtk#showdialog

ShowDialog() in Mono


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


Solution

  • 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 ();