Example of how to use closedHandler

9 posts, 0 answers
  1. Sandy
    Sandy avatar
    10 posts
    Member since:
    Jul 2009

    Posted 05 Nov 2011 Link to this post

    Hi,
    Can you please provide an example of how to use the WP& RadMessageBox closedHandler (for buttons)? Something simple like OK and Cancel is fine. The online documentation and sample code do not provide an example.

    Thanks,
    Sandy

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 07 Nov 2011 Link to this post

    Hi Sandy Lamoureux,

     Thank you for writing.
    Here is an example of how to use the closedHandler argument of RadMessageBox.Show().

    RadMessageBox.Show("Messagebox Title", MessageBoxButtons.OKCancel, "Messagebox Message", closedHandler: (args) =>
        {
            if (args.Result == DialogResult.OK)
            {
            }
            else
            {
            }
        });

    Please keep in mind that RadMessageBox does not stop execution of the code. Once the method is called RadMessageBox is shown and the Show method immediately returns. The lambda expression will be executed at a later time when one of the message box buttons are pressed.

    We will update the online documentation with this example.
    Please write again if you have other questions.

    Greetings,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Sandy
    Sandy avatar
    10 posts
    Member since:
    Jul 2009

    Posted 07 Nov 2011 Link to this post

    Thanks!
  5. Paul
    Paul avatar
    9 posts
    Member since:
    Dec 2011

    Posted 01 Dec 2011 Link to this post

    Could you please supply an example of using RadMessageBox in visual basic please as im stumped.
  6. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 01 Dec 2011 Link to this post

    Hi Paul,

     Of course, here is the same snippet in VB:

    RadMessageBox.Show("Messagebox Title", MessageBoxButtons.OKCancel, "Messagebox message", closedHandler:=Function(args)
                                                                                                                If args.Result = DialogResult.OK Then
     
                                                                                                                Else
     
                                                                                                                End If
                                                                                                            End Function)

    Best wishes,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  7. Paul
    Paul avatar
    9 posts
    Member since:
    Dec 2011

    Posted 01 Dec 2011 Link to this post

    Thank you Victor, and if I wanted buttons called OK and Email?
  8. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 01 Dec 2011 Link to this post

    Hello Paul,

     You can specify custom content for the buttons by using a different overload of the Show method:

    RadMessageBox.Show(New String() {"OK", "Email"}, "Messagebox Title", "Messagebox message", closedHandler:=Function(args)
                                                                                                                  If args.Result = DialogResult.OK Then
     
                                                                                                                  Else
     
                                                                                                                  End If
                                                                                                              End Function)

    Please have a look at our online documentation, there you will see all available overloads of the Show method. They are in C# but you will still be able to determine which one you need to use and invoke it from VB.

    Greetings,
    Victor
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Domi
    Domi avatar
    2 posts
    Member since:
    Nov 2013

    Posted 06 Jan 2014 Link to this post

    Hi Victor,

    it's an old post but can you complete it to avoid a re-post ...

    How can I stop the process until the user has clic on either a button or the other ? if I use the following code :

    private void button2_Click(object sender, RoutedEventArgs e)

    {

    RadInputPrompt.Show("Messagebox Title", MessageBoxButtons.OKCancel, "Messagebox Message", closedHandler: (args) =>

    {

    if (args.Result == DialogResult.OK)

    {

    MessageBox.Show("OK");

    }

    else

    {

    MessageBox.Show("Cancel");

    }

    });

    MessageBox.Show("Finished !");

    }



    the MessageBox is showed BEFORE the dialog with the InputPrompt appear !; I just want the input shows first, the user fills it, [ok] or [cancel] is displayed and THEN [finished], how can I achieved this ?

    a full source code would be wonderfull.
    thanks in advance,
    Domi.

  10. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 09 Jan 2014 Link to this post

    Hi Dominique,

    Thanks for writing.



    You should either rely on the ClosedHandler and put the Finished message box there or use the ShowAsync API and await it. The code execution after the awaited method will happen as soon as you close the input prompt.



    Regards,

    Deyan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.

    Sign up for Free application insights >>
Back to Top
DevCraft banner