473,503 Members | 7,578 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show second form in a windows app

Hey guys,
I have multiple forms in my windows app, and in my startup form i am doing
the following in order to navigate to a different form:

Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformname
myform.show

As soon as I try to run the application, the main form shows up, I try to
click the button to navigate to a different form but it just closes., without
navigating. any ideas? Thanks in advance

~Ken
Nov 21 '05 #1
9 1949
Ken,

I cannot see from the code you show now what is happening. I cannot see
where you have placed it, what is very important.

However your code is strange

Dim myform as New frmsecondform Instance a complete myform from the class frmsecondform
frmsecondform=mynamespace.originalsecondformname frmsecondform is a class(type) what is orinalsecondformname as well.
So I don't know what you want to do.
myform.show
Withouth the second line would this show the new instance of frmsecondform

I hope this helps?

Cor As soon as I try to run the application, the main form shows up, I try to
click the button to navigate to a different form but it just closes.,
without
navigating. any ideas? Thanks in advance

~Ken

Nov 21 '05 #2
Which form closes? The second one? Or does the app just close?
Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformnam e
myform.show


I'm sure what you're attempting to accomplish with the second line
above but if you leave it out and just call myform.Show, it should
work. Can you provide more information?

Chris

Nov 21 '05 #3
I apologize for the confusion, this is the code:

Dim myform as New Form
myform=myappname.originalsecondformname
myform.show

I am placing this code in a button Click Event. Just to make sure, I put
this following code in the second form load event:

MsgBox("hey i am here in the second form")

which is firing as soon as I click the button_Click in the main form.But I
cannot see the form., and everything closes after that(both the main and the
second form).

Thanks once again.

~Ken


"Chris Dunaway" wrote:
Which form closes? The second one? Or does the app just close?
Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformnam e
myform.show


I'm sure what you're attempting to accomplish with the second line
above but if you leave it out and just call myform.Show, it should
work. Can you provide more information?

Chris

Nov 21 '05 #4
"=?Utf-8?B?dHduZXR5MG5lQHlhaG9vLmNvbQ==?="
<tw***************@discussions.microsoft.com> wrote in
news:78**********************************@microsof t.com:
I apologize for the confusion, this is the code:

Dim myform as New Form
myform=myappname.originalsecondformname
myform.show

I am placing this code in a button Click Event. Just to make sure, I
put this following code in the second form load event:

MsgBox("hey i am here in the second form")

which is firing as soon as I click the button_Click in the main form.But
I cannot see the form., and everything closes after that(both the main
and the second form).


Is this the only code you have? Do you have anything after the Show method?
Is the form set to visible?
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Make your ASP.NET applications run faster
http://www.atozed.com/IntraWeb/
Nov 21 '05 #5
Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformname
myform.show
Instead of the above try :

Dim myform as New frmsecondform
myform.show

The second line "frmsecondform=mynamespace.originalsecondformn ame" is
unnecessary and I suspect it is the reason your form does not show.
Nov 21 '05 #6
ok., this is the original code(i am copy/pasting it)

what i am doing is., i am navigating to a different form based on the
formname stored in a variable called strFormNameHolder., but it doesnt work(I
cant see the second form).

Dim myForm As Type = Type.GetType(strFormNameHolder)
Dim myFormObject As Object =
Activator.CreateInstance(Type.GetType(strFormNameH older))
Dim frmNavigateto As New Form
frmNavigateto = DirectCast(myFormObject, Form)
frmNavigateto.Show()
frmNavigateto.Visible=true
Me.Close
Me.Dispose

This code is in a button_click sub, as soon as the event is fired., the
application seems to run and immediately close.
Thanks again.
~Ken


"ocertain" wrote:
Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformname
myform.show
Instead of the above try :

Dim myform as New frmsecondform
myform.show

The second line "frmsecondform=mynamespace.originalsecondformn ame" is
unnecessary and I suspect it is the reason your form does not show.

Nov 21 '05 #7
Also, all the other forms are not mdi forms- is that a problem?
~ken
"tw*******@yahoo.com" wrote:
ok., this is the original code(i am copy/pasting it)

what i am doing is., i am navigating to a different form based on the
formname stored in a variable called strFormNameHolder., but it doesnt work(I
cant see the second form).

Dim myForm As Type = Type.GetType(strFormNameHolder)
Dim myFormObject As Object =
Activator.CreateInstance(Type.GetType(strFormNameH older))
Dim frmNavigateto As New Form
frmNavigateto = DirectCast(myFormObject, Form)
frmNavigateto.Show()
frmNavigateto.Visible=true
Me.Close
Me.Dispose

This code is in a button_click sub, as soon as the event is fired., the
application seems to run and immediately close.
Thanks again.
~Ken


"ocertain" wrote:
Dim myform as New frmsecondform
frmsecondform=mynamespace.originalsecondformname
myform.show
Instead of the above try :

Dim myform as New frmsecondform
myform.show

The second line "frmsecondform=mynamespace.originalsecondformn ame" is
unnecessary and I suspect it is the reason your form does not show.

Nov 21 '05 #8
> Dim myForm As Type = Type.GetType(strFormNameHolder)
Dim myFormObject As Object =
Activator.CreateInstance(Type.GetType(strFormNameH older))
Dim frmNavigateto As New Form
You don't need the New keyword above, it creates a new form and you
have already done that by calling activator.createinstance.
frmNavigateto = DirectCast(myFormObject, Form)
frmNavigateto.Show()
frmNavigateto.Visible=true
Me.Close
Me.Dispose


I presume that Me refers to the main form which is the startup object
of your project? When you close this form, it closes the application.
If you wish to hide the main form while the second form is visible,
call its Hide method instead of Close and don't dispose the form
either.

Nov 21 '05 #9
No. You do not need to use mdi forms to do what you are trying to accomplish.

Have you had any success with the forms yet?

"tw*******@yahoo.com" wrote:
Also, all the other forms are not mdi forms- is that a problem?
~ken


Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6718
by: Venkat | last post by:
Hi All, I have got two windows namely parent and a child . My parent window has got a link, on clicking which opens a child window(i am using window.open function). I do the following set...
13
73970
by: genetic.error | last post by:
I'm moving from Vb6 to VB.Net. I have a feeling this has come up before... The VS.Net MSDN file seems to state that the following should work: Form1.Show Form1.Visible = True Form1.Hide...
2
2475
by: Ajai Kumar .R | last post by:
Hai all, I've two or more forms on my app. My requirement is, Have to show the first form asa the user press a button have to hide the first form and show the second form. If the user press the...
4
7811
by: BobAchgill | last post by:
What is the best way to show a video file directly in a Form? Can I use functions of Windows Player in a Windows Form? Functions like: play video or show visualization for music, etc.
0
4736
by: question | last post by:
Hi! I have a requirement where I need to display multiple forms one after the other like a slide show. These are in the same application. Basicall on selection of a menu item it should start...
3
4588
by: Avi G | last post by:
Hi, i work with VS 2005 and i need to know how to put the windows time(Clock) on my label that it is on the form that i will see the full time include the second as they move, and i need to know...
10
2421
by: =?Utf-8?B?QWxiZXJ0IEZ1?= | last post by:
Hi, my function: myAdjustForm.Show(); I am using the Show method to show the pop-up window to the users in my C# program. I found that I have invoke this function TWICE at the beginning...
4
2404
by: blackjack2150 | last post by:
Hi. Try this: Create a new VB.NET windows application and put on button on the form. Now add a new form to the project (Form2) and in the Click event handler of the button from the first form put...
2
12433
by: Curious | last post by:
I have a windows form, and it seems that I can use either Show or ShowDialog to get it displayed. I wish to know the difference between the two methods. Thanks!
0
7194
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
7070
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
7267
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
7316
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...
1
6976
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...
1
4993
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...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.