load another form form one form 
Author Message
 load another form form one form

The sample is simple, I create two forms in vb.net IDE, say Form1 and Form2,

When start the project, Form1 is started by default, but how to start Form2?

I tried to add a module, public f2 as Form2

In the Form2 InitializeComponent event, add the code

F2=Me

And then in Form1 's button click event, add

F2.show()

It does not work anything wrong here?



Sat, 21 May 2005 16:46:50 GMT  
 load another form form one form
Right click on your project and select properties.

There is a ComboBox to select 'Startup Object'

Cheers,

elziko



Sat, 21 May 2005 17:21:34 GMT  
 load another form form one form
Just do this in form1's button click event

dim f2 as new Form2()

f2.show()



Quote:
> The sample is simple, I create two forms in vb.net IDE, say Form1 and
Form2,

> When start the project, Form1 is started by default, but how to start
Form2?

> I tried to add a module, public f2 as Form2

> In the Form2 InitializeComponent event, add the code

> F2=Me

> And then in Form1 's button click event, add

> F2.show()

> It does not work anything wrong here?



Sat, 21 May 2005 18:52:03 GMT  
 load another form form one form
If it should be modal use

Dim f2 As New Form2()
f2.ShowDialog()
f2.Dispose()



Sat, 21 May 2005 19:09:28 GMT  
 load another form form one form
Thanks all for your posts. I think I have something confused. Now I am
cleared.

One thing I confused is that when I add a windows form by clicking
project->add windows form, actually, it adds a class; after I run the
project, there is no instance for the form2 class created, only one instance
of form1 is created by default, so of course I need to use new keyword to
create a new instance.

So I know now add a windows form actually create a class;

If I am wrong, please let me know. Thank you.


Quote:
> The sample is simple, I create two forms in vb.net IDE, say Form1 and
Form2,

> When start the project, Form1 is started by default, but how to start
Form2?

> I tried to add a module, public f2 as Form2

> In the Form2 InitializeComponent event, add the code

> F2=Me

> And then in Form1 's button click event, add

> F2.show()

> It does not work anything wrong here?



Sat, 21 May 2005 21:40:41 GMT  
 load another form form one form
That is exactly correct, and it's actually not much different than VB-6.  In
VB-6 the second form did not display until you used an instruction such as
Form2.Show. If the VB runtime detected a reference to a form that did not
yet exist, then it silently executed the equivalent of dim <form2> as New
Form2 (where <form2> is some magic internal reference that allowed you to
refer to the instance of Form2 as 'form2'). Now the variable declaration and
instantiating the object is up to you, and you must do it before attempting
any reference to Form2 or any of its objects.


Quote:
> Thanks all for your posts. I think I have something confused. Now I am
> cleared.

> One thing I confused is that when I add a windows form by clicking
> project->add windows form, actually, it adds a class; after I run the
> project, there is no instance for the form2 class created, only one
instance
> of form1 is created by default, so of course I need to use new keyword to
> create a new instance.

> So I know now add a windows form actually create a class;

> If I am wrong, please let me know. Thank you.



Sun, 22 May 2005 08:13:56 GMT  
 load another form form one form
Hi ther

Just call function of class Form2 lets say ShowForm
from form1 and then in that function write me.showdialog

It will work

dheeraj


Quote:
> The sample is simple, I create two forms in vb.net IDE, say Form1 and
Form2,

> When start the project, Form1 is started by default, but how to start
Form2?

> I tried to add a module, public f2 as Form2

> In the Form2 InitializeComponent event, add the code

> F2=Me

> And then in Form1 's button click event, add

> F2.show()

> It does not work anything wrong here?



Sun, 22 May 2005 12:16:30 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. How to have combo box in one form select record to be used in another form

2. Calling A Function In One Form From A Funciton In Another Form

3. Closing one form from another and resizing the entire form at runtime

4. One form triggering action on another form

5. One form "show" another form

6. Can anybody straighten me out on accessing one form's controls from another form

7. Windows Forms - Loading & Unloading Forms

8. VB Form Designer cannot load a form

9. Changing form-properties while running before loading the form

10. how to load a form from another form

11. Loading MDI Child forms to a parent form from a DLL

12. Loading a form within a form

 

 
Powered by phpBB® Forum Software