Results 1 to 13 of 13

Thread: Back to the previous form

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Back to the previous form

    How can I back to the previous form without loosing the data of the previous form.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: Back to the previous form

    Wow, that's a lot of detail. We don't know anything about how your app is structured so we couldn't really advise without guessing. I suggest that you read the Forms in VB.NET tutorial in my signature. The principles are exactly the same for C# and there are links to code converters in my signature to convert the example code.

  3. #3
    Lively Member
    Join Date
    Mar 2005
    Location
    Dhaka, Bangladesh
    Posts
    102

    Re: Back to the previous form

    Sohel,

    Put the data of previous form into Session. And retrive those when you came back to that form again....

    For example:

    Session["data1"] = abc;

    Again

    text1.text = Session["data1"];

    Best of Lucks....

    Rajib
    Please Rate every reply if it is useful to u

  4. #4
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Re: Back to the previous form

    Do you want to revert back to the data of the form or the form itself? If its the data you could use some kind of session. If its the form itself, then simply hide the form and when you want to revert back to it, you could re-show the previous form.

  5. #5
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Back to the previous form

    Eh? Is this a desktop app, or a web app?

    If it's a web application, you should post in the ASP.NET forum.

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Re: Back to the previous form

    It's a desktop application.

  7. #7
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: Back to the previous form

    Quote Originally Posted by zisohel
    It's a desktop application.
    You really are a man of few words, aren't you. See how everyone is guessing at what the situation might be? That's because you haven't given enough information. Tell us what you are trying to achieve. "Back to the previous form" could mean a number of different things. We don't know anything about your app so don't assume that we will assume the same things as you. Describe your situation and you'll get more accurate advice. Help us to help you.

    Also, have you read that tutorial? I'm quite sure that it will explain what you need to know, plus give you other importatnt information so you won't need to ask many potential questions in the future.

  8. #8

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Re: Back to the previous form

    Suppose I have two forms form1 and form2. In form1 user have to put the user id and password. If it is valid then the form2 will appear and form1 should not be visible. After doing the operation at form2 I want to back to the form1 and the user id should be visible in the textbox.

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Back to the previous form

    That's better

    Hide the first form and use ShowDialog() to show the second form, that will wait for it to be dismissed. Then just show self again.

    Code:
    this.Visible = false;
    
    Form2 theOtherWhatnot = new Form2();
    theOtherWhatnot.ShowDialog();
    
    this.Visible = true;
    Obviously, you would give things slightly better names than that.

  10. #10

    Thread Starter
    Member
    Join Date
    Feb 2006
    Location
    Dhaka, Bangladesh
    Posts
    40

    Re: Back to the previous form

    Thanks for your answer. I really want to do that.

  11. #11
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: Back to the previous form

    You'll also need to declare a public property in Form2 to return the user ID. You can then retrieve the value of that property once the dialogue has been dismissed.
    Code:
    this.Visible = false;
    
    Form2 theOtherWhatnot = new Form2();
    
    if (theOtherWhatnot.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        // Get the user ID from the dialogue.  You must defaine the UserID property yourself.
        this.TextBox1.Text = theOtherWhatnot.UserID;
    }
    
    // You should destroy the dialogue form.
    theOtherWhatnot.Dispose()
    
    this.Visible = true;

  12. #12
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Back to the previous form

    Isn't the user id being inputted in the current form?

  13. #13
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,467

    Re: Back to the previous form

    Quote Originally Posted by penagate
    Isn't the user id being inputted in the current form?
    Quite correct it seems. I didn't read that last properly. I did ask for it after all. I shouldn't have to read it too. I assumed that there was some desire to pass data between the forms but it would appear not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width