This is a migrated thread and some comments may be shown as answers.

Confirm in Static Methods

3 Answers 96 Views
Window
This is a migrated thread and some comments may be shown as answers.
Shanka
Top achievements
Rank 1
Shanka asked on 17 Sep 2010, 01:26 PM
public static bool DisplayInfoMessage1(string strMsg)
        {
           if (MessageBox.Show(strMsg, mstrProjectName, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                return true;
            }
            else
            {
                return false;
            }       
        }

I want to do this using the RadWindow.Confirm box Please Help I try it any times but cannot done it


RadWindow.Confirm(strMsg, new EventHandler<WindowClosedEventArgs>(OnClosed));        can not write inside static Method

private void OnClosed(object sender, WindowClosedEventArgs e)
        {
            
            if (e.DialogResult == true)
            {
                ConfirmationStatus = true;
            }
            else
            {
                ConfirmationStatus = false;
            }
        }
 
ConfirmationStatus  is Public Boolean value.

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 20 Sep 2010, 09:07 AM
Hello Shanka,

 As the Confirm method of the RadWindow class is an asynchronous (in contrast with the Show method of the MessageBox class) you cannot use its result as a return value of your method - the event handler will be called after the value is returned. If you give us some more details about the scenario we might be able to help you use the Confirm method in your case.

Kind regards,
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Shanka
Top achievements
Rank 1
answered on 22 Sep 2010, 04:44 AM
I want to Show Confirm and get Boolean value after Click Yes or No

i done it Application Closed event

 private void Exit_Click(object sender, RoutedEventArgs e)
        {
            RadWindow.Confirm("Do You want to Close ?", new EventHandler<WindowClosedEventArgs>(this.FormClose));
        }


        private void FormClose(object sender, WindowClosedEventArgs e)
        {
            if (e.DialogResult == true)
            {
                this.Close();
            }

        }

But The Confirm is used several times in my Project I want to pass my String and Get the answer true or False .
with out create instance of Class.Like

ClassName instance = New ClassNAme();
if (instance.MethodNAme("Are You Sure "))
{
  // My content
}


Please help

Thank you,
Shanka.
0
Miroslav Nedyalkov
Telerik team
answered on 27 Sep 2010, 10:27 AM
Hello Shanka,

 What you need to do cannot be achieved with the RadWindow control because of the way it works. What I would suggest you is to use the approach you currently use (with the Closed event handler).

Greetings,
Miroslav Nedyalkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Window
Asked by
Shanka
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Shanka
Top achievements
Rank 1
Share this question
or