PC Review


Reply
Thread Tools Rate Thread

Changing the main form

 
 
Tony
Guest
Posts: n/a
 
      20th Jul 2004
Hi,
How do you change the main form in visual basic .net 2003?

I have a form1 as the startup form. Based on a user response as to
which mode to run the program in, i would like to transfer control of
the program to form2 or form3 and close form1. However, if I close
form1, the application will close because it is the startup form.

I guess I could make form1 hidden and form2 or form3 modal, but i was
hoping there was a better way.

Thanks for you help,
Tony
 
Reply With Quote
 
 
 
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      20th Jul 2004
Tony,
I would add a Shared Sub Main to Form1, display Form1 as a dialog, then
based on the result pass a new Form2 or Form3 to Application.Run.

Something like:

Public Class Form1

Public Shared Sub Main
Dim dialog As New Form1
If dialog.ShowDialog() = DialogResult.Ok Then
Dim formMain As Form
If dialog.Response = UseForm2 Then
formMain = New Form2
Else
formMain = New Form3
End If
Application.Run(formMain)
End If
End Sub

Where Response is a property that indicates what the use selected.

Hope this helps
Jay

"Tony" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> How do you change the main form in visual basic .net 2003?
>
> I have a form1 as the startup form. Based on a user response as to
> which mode to run the program in, i would like to transfer control of
> the program to form2 or form3 and close form1. However, if I close
> form1, the application will close because it is the startup form.
>
> I guess I could make form1 hidden and form2 or form3 modal, but i was
> hoping there was a better way.
>
> Thanks for you help,
> Tony



 
Reply With Quote
 
Tony
Guest
Posts: n/a
 
      20th Jul 2004
Thanks Jay, that put me on the right track.
Tony


"Jay B. Harlow [MVP - Outlook]" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> Tony,
> I would add a Shared Sub Main to Form1, display Form1 as a dialog, then
> based on the result pass a new Form2 or Form3 to Application.Run.
>
> Something like:
>
> Public Class Form1
>
> Public Shared Sub Main
> Dim dialog As New Form1
> If dialog.ShowDialog() = DialogResult.Ok Then
> Dim formMain As Form
> If dialog.Response = UseForm2 Then
> formMain = New Form2
> Else
> formMain = New Form3
> End If
> Application.Run(formMain)
> End If
> End Sub
>
> Where Response is a property that indicates what the use selected.
>
> Hope this helps
> Jay
>
> "Tony" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > How do you change the main form in visual basic .net 2003?
> >
> > I have a form1 as the startup form. Based on a user response as to
> > which mode to run the program in, i would like to transfer control of
> > the program to form2 or form3 and close form1. However, if I close
> > form1, the application will close because it is the startup form.
> >
> > I guess I could make form1 hidden and form2 or form3 modal, but i was
> > hoping there was a better way.
> >
> > Thanks for you help,
> > Tony

 
Reply With Quote
 
Ray Cassick \(Home\)
Guest
Posts: n/a
 
      22nd Jul 2004
Try this out:

http://www.codeproject.com/useritems...ontextDemo.asp


"Tony" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> How do you change the main form in visual basic .net 2003?
>
> I have a form1 as the startup form. Based on a user response as to
> which mode to run the program in, i would like to transfer control of
> the program to form2 or form3 and close form1. However, if I close
> form1, the application will close because it is the startup form.
>
> I guess I could make form1 hidden and form2 or form3 modal, but i was
> hoping there was a better way.
>
> Thanks for you help,
> Tony



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing the main form Jordi Maicas Microsoft C# .NET 3 1st Jun 2008 05:10 PM
Changing subform backcolor from main form =?Utf-8?B?am9obmI=?= Microsoft Access Forms 8 5th Feb 2007 09:52 AM
Update Main Form from changing Sub Form =?Utf-8?B?QW5kcmV3?= Microsoft Access Forms 2 21st Jan 2005 11:55 PM
Changing the main form Tony Microsoft Dot NET 3 22nd Jul 2004 05:57 AM
Changing records in the main form Jorge Diaz Microsoft Access Forms 0 8th Mar 2004 07:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:01 PM.