Multiple Forms - Declare And Instantiate Second Form On Program Start - Use Button Simply To Show Form?
Jan 14, 2010
I have a program that uses two forms. The program opens to the Main form, and the user can navigate to the other form from the Main form through use of a button. Here's the way I've currently written it: When the Main form loads, it declares and instantiates the other form during the load procedure. When the user presses a button, the second form is displayed by means of the ShowDialog method. On the second form, there is a Return to Main Screen button which closes the second form, bringing the user back to the Main form.
So, here's the structure of the code:
Code:
Public Class frmMainForm
Dim frmSecondForm As New SecondForm
Private Sub btnSecondForm_Click(blah, blah, blah) Handles blah, blah, blah
[CODE]...
Here's my reasoning: Originally, I wrote the code so that a new instance of the second form was created every time the button was pressed. The problem was that whatever data was displayed on the second form, previously, was lost when the user returned to it a second time. Since the user would be switching back and forth between these forms, frequently, I needed that data to persist.
What is the best practice for accomplishing this:
1) Declare and instantiate the second form on program start, as I have done, and use the button simply to show the form?
2) Declare and instantiate the second form each time the button is pressed but maintain the variables on the Main form and pass them ByRef to a custom constructor for the second form? Is this even possible?
3) Something else?
View 5 Replies
ADVERTISEMENT
Dec 18, 2009
why I need to instantiate a form instead of form.show?
View 20 Replies
Mar 28, 2010
How the program's form could start from down to up when the program just runs?
View 6 Replies
Feb 23, 2009
i have uploaded 3 pics shows 3 diff forms.
1. BaseForm.( Includes 2 button, Buttons Text "Form1" and "Form2")
2. Form1. (Just inherited BaseForm)
3. Form2. (Just inherited BaseForm)
If the Button Form1 clicked then it shows Form1 disable Form1 button. and Hide BaseForm. same action for Button Form1.
When I click the Right Top Cross button then the Background BaseForm Still running. I want to close all form If I click cross.
View 6 Replies
Apr 28, 2011
I have just built a full main menu for my pc game and need to terminate the running program using a button held within the form. I have built a button labeled exit and tried a couple of closing codes such as:
Me.Close
ExitApplication
View 2 Replies
May 5, 2010
I used different backgroundworkers to instantiate some 'heavy' forms thinking that it will reduce the time to instantiate them if I did them at once but it looks like I am wrong since it is still taking about 43 seconds to load all of them. Am I missing something or do you have a tip on how I can speed up their instantiation?
View 15 Replies
May 31, 2009
I created a second form in my application and in the first form i wrote:
Dim frmDialog as new form2
But it does not recognize the second form. I tried changing the name and i get the same result.
View 9 Replies
Jun 20, 2012
I am currently working on a program that has several buttons in it lined up. Each button goes to different applications (.exe programs). The program I am making is suppose to be a fullscreen program and won't let you see any of Windows when it's running.
Therefore I want to make a "back" button that always stays on top of any application and when I push it it will take me back to my WindowsForm (startpage of the program).I am also wondering if you can make it so all .exe programs only can run ONCE. So if I press one of the buttons saying "open notepad" I want it to work so it can't open Notepad once again making it two notepads open. Just go back to the first Notepad opened.
View 3 Replies
Mar 5, 2009
Iam creating an application. i have a main form it has 5 buttons i have created 5 more forms. my aim is to show a particular form for every button the form is opened in a new window i dont want to open in a new window it should be embed in the main form when i click anthor button it will show the related form in place of previous form
View 2 Replies
Mar 5, 2009
Iam creating an application.i have a main form it has 5 buttons i have created 5 more forms.my aim is to show a particular form for every button the form is opened in a new window i dont want to open in a new window it should be embed in the main form when i click anthor button it will show the related form in place of previous form?
View 1 Replies
May 13, 2011
I want to open a form when the start button is pressed.
View 5 Replies
Feb 9, 2011
In this code the program did not show me the screen and start loading.I see the Form when they has finished with the load of the file
Private Sub Main_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TotalRecords = 0
Call Find_Total_Records()
[code]....
I want the program FIRST show me the screen and after i see the form to start load the file I have try with the 'Application.DoEvents() and System.Threading.Thread.Sleep(200) without any effect?
View 3 Replies
Oct 27, 2011
I have a few forms that have a lot of really intensive updating along with a great deal of user interface (text boxes, button clicking etc) Is it possible to open a separate form as a separate UI thread from the start up form that called it to "show" or open or whatever the new method might be?
View 6 Replies
May 30, 2011
Basically with the code below I would like to create multiple threads. Let's say user input was the number 100 for the "userVal" variable of type integer. With the first pass of the loop, starting with 1, I would like to[code]...
View 10 Replies
Apr 27, 2010
I have a multiple form application with a listbox on each form. I want to be able to select an item in one listbox on one form and then click a button and it show up in a listbox on another form.
View 3 Replies
Mar 28, 2010
How the program's form could start from down to up when the program just runs?
View 2 Replies
May 24, 2009
Is there a simple way to show multiple images on a form?
(Somting like this?
-> Movie (American Gangster) = Picture 1
-> Movie (American Pie) = Picture 2
the data must be variable....
View 1 Replies
Aug 13, 2010
I am creating a Jeopardy type game and I want to be able to have the same form show on multiple monitors at times and at other times show a form only on one monitor. I have no problem getting a form to show up on the second monitor, but when I try to show the same form on multiple monitors I run into problems.[code]...
View 3 Replies
Dec 15, 2011
wen i open mdi through the login form, the forms inside the mdi child forms dont seem to execute.
View 2 Replies
Oct 28, 2009
How can i display (show) the same form multiple times? Lets say Form2. This code only shows the form once: Form2.Show()
View 10 Replies
Aug 3, 2011
I have a class that inherits the UserControl class, the class creates its own graphics such as a title bar and what not. Is it possible to show this class as a form/it's own window?
Public Class CustomForm
Inherits System.Windows.Forms.UserControl
'create new instance, assign/declare vars here, blah blah
[Code]....
View 2 Replies
Feb 21, 2009
How to set child form start position in vb.net that will be work in different screen resolutions
View 1 Replies
Jun 7, 2011
to open Tabpage 2 when i click button 1 on Tabpage 2, how to do it
View 8 Replies
Dec 7, 2010
I have a form to create staff.
Hence after a new staff created, user can click on new button at the bottom to show a new staff form and close the previous one (parent form).
I have the following code under new button click event but i found that the previous form (parent form) somehow is still held in the memory.
What is the correct way to implement this and make sure parent form is released from the memory every time i click on the new button?
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
Dim frmChildForm As New frmStaffCreate
[Code]....
View 3 Replies
Oct 21, 2009
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]....
The end result is baffling me here are 2 examples when I debug
Mine: 640.1 * 49 = 31364.9
Debugger: 640.1 * 49 = 31360 ( not right needs to show the correct decimal )
Mine: .775 * 3 = 2.325
Debugger: .775 * 3 = 2.325 ( shows it perfectly???)
View 1 Replies
May 26, 2009
im working on a little project and i need my form1 to basically spam itself in random locations...
View 5 Replies
Jul 12, 2010
I have a form with multiple DataSets (filled by multiple Stored Procedures) and corresponding DataAdapters. Associated with the DataApters are commands for UPDATE, INSERT......... Before using the DA Update I am using 'If DSxyz.HasChanges(). It seems that when I make a change anywhere on the form affecting 1 dataset, all of the datasets show this to be true. Why should changing one dataset on a form cause all of the datasets to show changes?
View 1 Replies
Apr 28, 2012
In my vb.net windows form application i want make a button that when a user cliked the button, the Desktop should be showed, (Show Desktop Button) .Consider a form name as form1 and it got a button like "Show desktop", when user clicked, all the application should be minimized and it should show desktop, is there any Code for VB.NET Windows Form application.
View 2 Replies
Sep 14, 2011
I have the need to have a close button on a borderless form but I'm unable to find a way to display the win7 close button this way? Is it avalible in any way? (I dont wan't to do it the ugly, ugly, ugly way, IE do a screenshot and use that as a bitmap on a button)
View 9 Replies
Sep 7, 2011
I want when I click a button , it show form2 but if i click it again , it don't show form2...
View 1 Replies