Skip to content

Custom dialogresult...yes/yes to all/No/Cancel...plz help

Basu Biswas

Asked Jan 18, 2007, 3:51 AM EST4 answers
Share
LinkedInX

Hi,

     In my application i am restoring my files from the server to my desktop application in the same location(drive) it was before. Like c:\a\b\text.txt.

Now while restoring if text.txt file allready exist I need to show a pop up form with options like..

/ ..................................................................................../

       This folder allready contains a file called text.txt

       Would u like to replace the existing
        text.txt
        last modified : 06/06/06

        with this one
        last modified : 08/08/08

       YES            YES to All            No          Cancel

/ ..................................................................................../


I tried making a saparate form....but when i click yes/no/cancel/yes to all/(hiding this form) how the other form will know what the user has clicked so that It can form the specified task...

Please help....

Biswas

4 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    In your form you make an enumerator like
    enum BoxResults { YES, YESTOALL, NO, CANCEL }

    Then you make a private variable in your form like this:
    private BoxResults buttonClicked = BoxResults.CANCEL; // setting to cancel, if user clicks the red cross

    And then depending on which button he clicks, before closing, you'll do something like: buttonClicked = BoxResults.Yes;

    Then finally you make a property to retrive the result, as such:

    public BoxResults ButtonClicked
    {
    get { return buttonClicked; }
    }

    And in the form that calls the box/needs the result, use the code like this (we assume the above form/box is called ConfirmBox)

    ConfirmBox box = new ConfirmBox();
    box.ShowDialog();
    ConfirmBox.BoxResults result = box.ButtonClicked;
    switch(result)
    {
    case ConfirmBox.BoxResults.YES:
    // Do stuff
    break;
    case ConfirmBox.BoxResults.No:
    // Do something else
    break;
    }

    And so forth.
    0
  • 0
    Thank you very much MARTIN .....it works....
    0
  • 0
    One more thing martin...how can i make this form as a custom control....as like a .dll file which i will include in any projectc and use it as my own dialog box....
    0
  • 0

    Hi .....i want sum hint and suggesstion if anyone can provide.....

    i want to make one custom control which i will be using in different project....let me explain....

    I made one dialogue box....now i want to make it a custom control...say i will b makin a .dll file of it which i will include in my project and use that dialogue box as another control..

    How can i do that....

    let me make u clear....i know nothing about making such controls....

    if anyone suggesst me sumthing ....i'll be greatful to u...

    .............................

    Hope sumday i will b helpin others here....lol

    0