473,397 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

how to go to previous form

by clicking a button at form2 i went to form3 but again from form3 i wnt 2 go 2 frm2by clicking a button in frm3
Jul 29 '10 #1
2 2617
I am not sure whether there is any inbuilt mechanism to get the previous form, If it is there then i dont know
but it there is none then you can do following.

1. Create a Form Type variable. Name it Current Form
2. Whenver u create a new instance, you store CurrentForm instance to PreviousForm Insance and new insance inthe CurrentForm Reference.
3. Whenever you want to open previous form you access PreviousForm.Show() to show it.
4. Create the funcationality using above logic.

Best of luck...
Aug 10 '10 #2
GaryTexmo
1,501 Expert 1GB
What fastestindian suggested is spot on; however, an alternative for a cleaner interface is to use UserControls to populate a panel instead of separate forms.

For example...

Expand|Select|Wrap|Line Numbers
  1. public class WizardPanel : UserControl { ... }
Now you can create a bunch of WizardPanel objects and design them using designer to look like however you want.

Expand|Select|Wrap|Line Numbers
  1. public class MyPanel1 : WizardPanel { ... }
  2. public class MyPanel2 : WizardPanel { ... }
  3. public class MyPanel3 : WizardPanel { ... }
Expand|Select|Wrap|Line Numbers
  1. public class Wizard
  2. {
  3.   private List<WizardPanel> m_panelList = new List<WizardPanel>();
  4.   private int m_currentIndex = 0;
  5.  
  6.   public void Add(WizardPanel panelToAdd) { ... }
  7.   public void Remove(WizardPanel panelToRemove { ... }
  8.   public void Remove(int index) { ... }
  9.   public WizardPanel Get(int index) { ... }
  10.   public WizardPanel GetFirst() { ... }
  11.   public WizardPanel GetNext() { ... }
  12.   public WizardPanel GetLast() { ... }
  13.   public WizardPanel GetPrev() { ... }
  14. }
Create a Wizard object as a private member in your main form. Also throw two panels onto your form. Dock one to fill and the other to the bottom. Put a next/back button in the lower button.

In your constructor, you can put...

Expand|Select|Wrap|Line Numbers
  1. myWizard.Add(new MyPanel1());
  2. myWizard.Add(new MyPanel2());
  3. myWizard.Add(new MyPanel3());
  4.  
  5. mainPanel.Controls.Clear();
  6. mainPanel.Controls.Add(myWizard.GetFirst());
Your next button's click event ...

Expand|Select|Wrap|Line Numbers
  1. mainPanel.Controls.Clear();
  2. mainPanel.Controls.Add(myWizard.GetNext());
... and the back button ...

Expand|Select|Wrap|Line Numbers
  1. mainPanel.Controls.Clear();
  2. mainPanel.Controls.Add(myWizard.GetPrev());
This is just a stubbed out, bare bones version of a way to get the functionality you want inside a single form instead of instantiating new ones. It may not be what you need (as I said, I think fastestindian's answer is the best solution for what you described) but it's always fun to think about other ways to go about it :)

Good luck!
Aug 10 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: madmanpierre | last post by:
I'm having a trouble (sp3 installed) with mobile .net In form 1, in dadaGrid_MouseDown, I am showing another form. No matter what I seem to try (such as this.visible=false), after I show the...
1
by: MissiMaths | last post by:
I am creating a reference table of all the information used to draw a sample. I start by first clearing the table in form1 using a delete query. Then after the user selects certain options, i...
8
by: Cheryl | last post by:
How can I create a button that would take me back to the previous form not the previous record, but the previous form that I just moved from using VBA? Any sample code would be greatly appreciated.
3
by: Eagle-i | last post by:
In Visual Studio.Net I've created 2 forms for a Windows app using VB.Net - lets say the forms are frmAlpha and frmBeta By default the app opens in frmAlpha. On button click I want to go to...
12
by: djmauro | last post by:
as title says. I cant find a way to do this. if i use form1.show and click on a button. it opens that form, but as soon as i click again it just reopens it and closes previously opened form. So is...
3
by: Gilberto | last post by:
Hello This must be pretty simple but i havent found the way to do it. I have a form with a button that opens another form on click. WHAT command and WHERE do i need to CLOSE the previous form...
1
by: sweatha | last post by:
Hi Friends I have designed a form with 1 DropDownList box named “ddlShow_time”& the form name is “Default4.aspx”. Just like that, I have the database(SQL SERVER 2000) as Table Name: ShowTime...
9
by: Brett_A | last post by:
I have a form where the first field is a dynamic drop-down that pulls from a db (Access). The fields associated with the query are task_id, task_name and task_rate. The field has the value of...
5
by: danon | last post by:
Hi to you all can any one tell me how to programme a button so it can take back to the previous form please many thanks
1
by: jackie10579 | last post by:
I am in desperate need of some help to write some code for templates I need for work. I want to write a number of different options but I need to know how to do a basic code and have fields come...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.