This project has moved and is read-only. For the latest updates, please go here.

InformationBox modeless behavior

Starting from version, it is possible to set the InformationBox as modeless. Doing so will allow you to access the parent window while displaying the InformationBox.
It is recommended when you want to show alerts for non critical errors in a time consuming process.

In case of a box asking the user to choose between multiple actions (yes/no, Ok/cancel, etc), it is not a good choice to use a modeless box. But if you really to do so, you will need to obtain the InformationBoxResult for the box. You just have to pass a delegate in the parameters of the Show method.

Example 1
This example is taken directly from the designer and demonstrates a simple callback.

The callback method
/// <summary>
/// Call when a asynchronous InformationBox is closed.
/// </summary>
/// <param name="result">The result.</param>
private static void boxClosed(InformationBoxResult result)
    InformationBox.Show(String.Format("I am the result of a modeless box : " + result));

The parameter passed to the show method
new AsyncResultCallBack(boxClosed)

Example 2
For those (like me) who love anonymous methods, here is how you can do with modeless boxes :

An anonymous method
                    (AsyncResultCallBack) delegate(InformationBoxResult result)
                        { MessageBox.Show(result.ToString()); });

You just have to cast the delegate into the AsyncResultCallBack type.

Last edited Jan 24, 2008 at 9:22 PM by SaumonAgile, version 4


No comments yet.