Avatar of Terrygordon
Terrygordon

asked on 

Preserve the state of multiple forms

Hi all

I am designing an application where the user can enter information on different forms that are accessed from a main window. Each form contains a combination of text boxes, radio buttons, etc.

The problem I am having is that if the user closes the form (using the standard X button at the top of the form) and then loads it again from the main window, the form returns to its default values and doesn't save the values that the user entered.

I did consider using tabs instead of separate forms, but there will be situations where the user will want to compare the entries on several forms simultaneously.

So, is it possible (without having to write code to store all the variables and reload them) to save the state of the form when it has been closed and reproduce the user's entries when it is opened again?

P.s. I am quite new to visual studio programming.

Thanks in advance.

Terry
Visual Basic.NET

Avatar of undefined
Last Comment
Terrygordon
Avatar of dj_alik
dj_alik

What is desired
 
You do not want the user to be able to click on the Close button (the little "x" in the upper right).
 
Method #1: The ControlBox property
 
The WinForm ControlBox property is a good place to start, but it shows or hides the entire control box. That means it either shows or hides all three buttons. That isn't useful because one maywant the minimize and maximize buttons to work or because one may want those buttons to appear for visual consistency.
 
Method #2: Disabling the Close button directly
 
This thread on microsoft.public.dotnet.framework has a solution
 
The result:
- the control box is still visible (min, max, close)
- the close button will appear disabled
- clicking on the close button will not do anything

Save
Avatar of dj_alik
dj_alik

Also:
Use Windows Forms Application Settings to Personalize Your Applications
http://www.devx.com/dotnet/Article/34273/1954
Avatar of dj_alik
dj_alik


And in addition you can use MDI Form for Multiple Document Interface applications
Developing MDI Applications
http://www.c-sharpcorner.com/UploadFile/ggaganesh/DevelopingMDIAppplicationsinCSharp11272005225843PM/DevelopingMDIAppplicationsinCSharp.aspx
 
Avatar of Terrygordon
Terrygordon

ASKER

Hi dj

The "Disabling the Close Button Directly" solution looks like it might work, but you haven't included a link to the thread. Can you post it?

Regards

Terry
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Terrygordon
Terrygordon

ASKER

Hi Codecruiser

This is perfect.....and brilliantly simple. Does exactly what I want.

Regards

Terry
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo