Gtk.MessageDialog Class
Convenient message window

See Also: MessageDialog Members

Syntax

public class MessageDialog : Dialog

Remarks

Gtk.MessageDialog presents a Gtk.Dialog with an image representing the Gtk.MessageType (Error, Question, etc.) alongside some message text. It is available as a convenience. You could construct the equivalent of Gtk.MessageDialog from Gtk.Dialog without too much effort, but Gtk.MessageDialog saves typing.

The Gtk.MessageDialog is displayed using Dialog.Run(), which automatically makes the Gtk.MessageDialog modal and waits for the user to respond to it. Dialog.Run() returns when any Gtk.Button in the Gtk.Dialog is clicked or the Gtk.MessageDialog is closed.

After Dialog.Run() returns, you are responsible for hiding (using Widget.Hide()) or destroying (using Widget.Destroy()) the dialog if you wish to do so.

A simple message dialog

C# Example

MessageDialog md = new MessageDialog (parent_window, 
                                      DialogFlags.DestroyWithParent,
	                              MessageType.Error, 
                                      ButtonsType.Close, "Error loading file");
	
int result = md.Run ();
md.Destroy();
  	  

A yes/no message dialog

C# Example

MessageDialog md = new MessageDialog (parent_window, 
                                      DialogFlags.DestroyWithParent,
	                              MessageType.Question, 
                                      ButtonsType.YesNo, "Are you sure you want to quit?");
	
ResponseType result = (ResponseType)md.Run ();

if (result == ResponseType.Yes)
	Application.Quit();
else
	md.Destroy();
  	  

If you would like the Gtk.MessageDialog to not be modal, set the property Dialog.Modal to false.

Example

md.Modal = false;
		  

Requirements

Namespace: Gtk
Assembly: gtk-sharp (in gtk-sharp.dll)
Assembly Versions: 2.12.0.0