473,406 Members | 2,847 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,406 software developers and data experts.

Changing form on submit

hello everyone,
i am new here and i am also a new programmer and i am learning c#..i am using visual studio 2008 and started to build some very simple windows form apllication and now i am facing a problem.
how can i open a new form to replace the old form in a way such that when i close the second form ..all of the application gets terminated..something like the installation wizard of a program or a game..when you hit the next button the window form changes completely and whenver i press the (x)button on top right the installation wizard terminates completelly..i hope someone helps me as i really need to learn that so i can keep going

i hope i can find the help i need here..thanks all in advance
Feb 23 '10 #1
7 2242
tlhintoq
3,525 Expert 2GB
My suggestion is to not use multiple forms.
Use one form.
Put a panel on it: Dock set to full.
Then keep putting new UserControls on the dock.
That way you can flip through 'screens' one UserControl at a time, then exit when you are done.

Also "I need help" is hardly an informative title. What if all 1,000 posts a day said that?
Please visit the Posting Guidelines for tips on how to ask questions to get the best help.
Feb 23 '10 #2
ThatThatGuy
449 Expert 256MB
On the second form on the Forms FormClosing Event type
this.Hide() or this.Close()...
will hide the second form ... and will not terminate the whole application
Feb 23 '10 #3
@tlhintoq
first of all thank you so much for your help an i alos apologize for notreading the ruels of postin a question..it was so late(3 am)and i was so tired and hardly opened my eyes..programming learning is harder that i thought,

i was hoping you can tell me what do you mean by : (Put a panel on it: Dock set to full)
i am new to c# and only started learing it like 7 days ago..i still have to figure this one out b4 i move on to learning about XML files and i also hope you will help me with that if i needed help and don't worry..the next time ,i will write an appropriate title for my thread.

@ThatThatGuy

thanks alot for your help..you gave me a great first impression about his forum and i am hoping to continue with you guys here and hopefully be a good programmer someday..thanks alot for your help
Feb 23 '10 #4
tlhintoq
3,525 Expert 2GB
i was hoping you can tell me what do you mean by : (Put a panel on it: Dock set to full)
Sure. It doesn't really have to be done this way... I just find it easy to use the panel as a reference.

You have a form, probably named "Form1" by Visual studio...
From the Toolbox, drag a "FlowLayoutPanel" to the form. Visual Studio will name it FlowLayoutPanel1.
Go to the Properties pallet.
Set AutoScroll to true.
Set Dock to fill
Go back to the form designer. Right-click on the form. Choose "View Code". It should look similar to this:
Expand|Select|Wrap|Line Numbers
  1. namespace DemoPOS
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.     }
  10. }
  11.  
Add the new code shown:
Expand|Select|Wrap|Line Numbers
  1. namespace DemoPOS
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         Control.ControlCollection WorkZone
  11.         {
  12.             get
  13.             {
  14.                 return flowLayoutPanel1.Controls;
  15.             }
  16.         }
  17.     }
  18. }
  19.  
This is a read-only property (because it only has a 'get' method and no 'set' method, that will return all the controls in the FlowLayouPanel you just dropped on the form. This makes for a more convenient reference in your code later.

Now make all those different 'Wizard-like' steps that you need. Make each one as a UserControl instead of as a form.

Add and remove controls from the WorkZone as needed.
Expand|Select|Wrap|Line Numbers
  1.         public void Step2()
  2.         {
  3.             ucStageTwo myStepTwo = new ucStageTwo();//ucStageTwo is the user control you made to be your second Wizard page
  4.             WorkZone.Clear();
  5.             WorkZone.Add(myStepTwo);
  6.         }
  7.  
Feb 23 '10 #5
@tlhintoq

thanks alot ..i really really appretiate your help..thanks so much...i will try the solution you suggested and tell you the result asap..
thank you again and i am so glad that i subscribed on this great forum,.
Feb 23 '10 #6
@tlhintoq


i tried as u said ...and i didn't get the result i am looking for..i knw i may be a pain in the ass but i really want to learn...i hope if you can give me a full example of simple two pages wizard..the first one with a button on it called next and the second one(panel) is the one which appears when i click the next button..i hope you give me a detailed program code for it..so i can completelyy understand how it is done and start working on my dsired function...i apologize again for asking too much..thanks and i hope you continue helping me and don't give up on me
Feb 23 '10 #7
Bassem
344 100+
On the second form on the Forms FormClosing Event type
this.Hide() or this.Close()...
will hide the second form ... and will not terminate the whole application
I don't think so.

The event fire while the Form is closing. So, hiding the form closing the from will not make a change, after all the form is closed.

Thanks,
Bassem
Feb 24 '10 #8

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

Similar topics

3
by: Emanuel Marciniak | last post by:
Hi all, We have the form which uses checkboxes for several fields and the target action points to outside webservice. Unfortunatelly they do not support checkboxes. How to pass it as a radio...
7
by: Michel | last post by:
Hi folks, I wonder if what I have in mind is possible, maybe even not all that complicated: I have an image, which is a yellow circle. I want this yellow circle to change color by having 3...
2
by: Bartosz Wegrzyn | last post by:
I do have a form with 4 submit buttons. Also I do have a script that checks that for for errors. Right now I have onsubmit() event for checki my form. After it is checked it runs my php script....
3
by: jeff | last post by:
Hello, I have a form that submits it's values to a pop-up window. I've simplied the code: <form name="formname" action="action.php" target="windowName" method="post" onsubmit="window.open('',...
2
by: Claire Osborne | last post by:
I have made a form at http://www.lcuk.org/cleanair/form.htm In the Financial Information section there is a question "How do you wish to pay?" If the user selects "invoice" then when the user...
8
by: Ryan | last post by:
I have a hidden field as such: <INPUT TYPE=\"hidden\" name=xmlfield > I have a button that i want to use to call a function to change the value: <INPUT TYPE=submit VALUE="Display XML"...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
6
by: iwearwatches | last post by:
Group, What a root canal. Here is what I have: I have a page that has several layers that I will either show/hide based on a graphic/tab that the user clicks. (works perfectly)
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
1
by: Chuck Anderson | last post by:
I'm using a simple, pseudo progress bar. Very simply, I display a still image next to a form submit button until the user clicks on it, and then I change the image source to an animated version of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.