473,625 Members | 3,134 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 3987
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
8868
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
2004
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 is submitting will process the data and render the
4
2597
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 English.
2
2834
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 through the Display properties in the Control Panel. Sample lines of code, in simplest form:
6
9069
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 tried adding some javascript to LinkButton.Attributes: LinkButton1.Attributes.Add("onclick",...
10
14360
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 application itself.) I'm now trying to selectively enable the themes for just my form, or just...
7
2873
by: Marco Castro | last post by:
How can I disable and then re-enable the close button on a form? Thanks.
8
2028
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 it doesn't do anything until the other processing has finished :-)
3
7093
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 txtdoc.Enabled = False
0
8259
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8696
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8358
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7188
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6119
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4195
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1805
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1504
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.