473,562 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Enabling/Disable/Hiding main Form

I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?
Nov 20 '05 #1
5 3984
Code for Form1 Button:

Me.Hide()
Dim Form2 As New Form2()

Form2.Show()

Code for button on form2 to get back to form1

Dim form1 As New Form1()

form1.Show()

Me.Close()


"Ivan" <Iv*****@aol.co m> wrote in message
news:0f******** *************** *****@phx.gbl.. .
I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?

Nov 20 '05 #2
* "Ivan" <Iv*****@aol.co m> scripsit:
I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?


<http://www.google.de/groups?selm=u%2 3xQOutWDHA.2100 %40TK2MSFTNGP11 .phx.gbl>

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Hi Ivan,

This isn't the OOP approach but...

Public Module SomeGlobals
'This reference is used by the other forms.
Public oMainForm As Form1
End Module

Class Form1
Sub New
oMainForm = Me
Sub btnShowFormX_Cl ick
Me.Hide
Dim F As New FormX
F.Show

Class FormX
Sub btnReturnToMain Form_Click
Me.Close
oMainForm.Show

The reason the reference to the main form is stored in the SomeGlobals
Module is that you can't use Form1 to access the Form itself, as you could in
VB6.
Another method would be to pass the main form to FormX when you create
it - New FormX (Me). FormX would then store the reference internally. But that
would have to be done for every other form that may return to the main form.

Regards,
Fergus
Nov 20 '05 #4
If you're not ready to take the .NET form design architecture leap in its
entirety (I'm not), you can do something like the VB.NET form upgrade wizard
does. You can then access the form just like you used to for the most part
with show / hide: myforms.Custome rForm.Show for example.

Public Class myForms
Private Shared _CustomerForm As CustomerForm
Public Shared Property CustomerForm() As CustomerForm
Get
Return _CustomerForm
End Get
Set(ByVal Value As CustomerForm)
_CustomerForm = Value
End Set
End Property
End Class
End Class

Duncan Mackenzie (one of my favorite VB authors btw) has a good article
about getting a handler on what you are dealing with on MSDN:

http://msdn.microsoft.com/library/de...adingtonet.asp

--
Justin Weinberg

Designing a PrintDocument? Drawing to forms?
Check out GDI+ Architect at www.mrgsoft.com
"Ivan" <Iv*****@aol.co m> wrote in message
news:0f******** *************** *****@phx.gbl.. .
I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?

Nov 20 '05 #5
On Tue, 14 Oct 2003 08:09:06 -0700, "Ivan" <Iv*****@aol.co m> wrote:
I am used to VB6 and am not sure how to do this in
Vstudio .NET. I have a main form which calls other
forms. I want to disable that main form while other ones
are called. I tried hiding it and creating a new instance
of the main form when returning to it but than my
application is just creating more forms. How do I hide
the main form and return back to it when exiting another
form?

I tend to think of forms as just another class just with ui objects

As with all classes you can add a handler to a class event.
Now when you inherit from Inherits System.Windows. Forms.Form
you class gets an Closing event. I would just create a function that
can handle the second class's Closing event

kinda like this

'In Main Form

Dim login As New Login()

AddHandler login.Closing, AddressOf Login_UnLoad
login.ShowDialo g(Me)
Me.Visible = False
No further down in the main form class I would have this

Private Sub Login_UnLoad(By Val sender As System.Object, ByVal e As
System.Componen tModel.CancelEv entArgs)

'Perform Business Logic
Me.Visible = True

End Sub

now when the login form is unloaded it will raise an event of Closing
and my procedure that I added the handler to will catch that event and
procede wiht making my main form visible again
Nov 20 '05 #6

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

Similar topics

12
8865
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
4
2001
by: Frank Way | last post by:
Hi all, I've googled this one to death, and still can't find an answer. Not sure I'm asking the right question, but here goes: Have a form with an onSubmit that has some javscript to disable the submit button. When the user clicks submit, the value of the button changes to "Processing..." and the button disables. The cgi to which it...
4
2592
by: Old Lady | last post by:
Hi, I need help! I have a SELECT/OPTION list. My goal is to have a TEXT input field in a form that is normally disabled, but it should become enabled when the user select one predefined OPTION. If the user change idea and select another OPTION, the TEXT input field should be disabled again. I hope I'm understandable. Sorry for my bad...
2
2831
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have been successful in disabling the Screen Saver, but it does not work for re-enabling. The only way I can re-activate it is to re-apply the settings...
6
9065
by: Al Cohen | last post by:
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed. I'd like to disable my LinkButton during this period to prevent multiple submissions. (Obviously) the disabling should be done at the client side to prevent any delay. I've...
10
14346
by: Robert Jacobson | last post by:
Hi, I'm develing a COM add-in for Microsoft Word XP that displays a form. I'd like to have the form display using the Windows XP theme. However, neither using a manifest nor calling Application.EnableVisualStyles does the trick. (EnableVisualStyles works but massive instability, probably because the system is trying to theme the Word...
7
2865
by: Marco Castro | last post by:
How can I disable and then re-enable the close button on a form? Thanks.
8
2016
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for button A's mouseup has completed? I beleive event processing to be single-threaded for good reason but I need a "stop" button and it's no good if...
3
7081
by: Timas | last post by:
Hi I'm a bit of a newbie on Access. I'm using Access 2000 and am trying to disable some fields on a form based on the values selected in other fields on the same form. I'm using the AfterUpdate function on the fields to enable / disable the fields: ------------------- Private Sub field1_AfterUpdate() If field1.Value = "Partial" Then...
0
7579
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7874
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7630
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7940
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6228
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2075
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 we have to send another system
1
1192
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
907
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.