Reputation: 572
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;
this question mean: i want to show Form2 but Form1 wait for result of Form2
Upvotes: 1
Views: 3436
Reputation: 3010
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".
Upvotes: 0
Reputation: 4420
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 ();
Upvotes: 1