473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Hide a form as it loads

Can anyone tell me why this code does not work?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub

If runs, but the form won't hide itself. This is the main form of the
application.

to duplicate, just start a brand new windows application, double click the
default form and enter Me.Hide().

I really need this to work. Any thoughts?

Thanks

Kirk
Nov 21 '05 #1
5 2212
Kirk,

To hide a form as it loads, you need to move your initialisation code to a
different place - the constructor - Public Sub New(). For example;

Class StartApplicationHere
Sub Main
Dim gvMainForm As New Form1 ' Form initialising here while hidden
Application.Run(New Form1) ' Form shown here
End Sub
End Class

Class Form1
Sub New()
' Do initialisation here while form is hidden
End Sub
Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Shouldn't need to do a lot here
End Sub
End Class
_________________________________
The Grim Reaper

"Kirk Graves" <kr***********@yahoo.com> wrote in message
news:ea**************@TK2MSFTNGP10.phx.gbl...
Can anyone tell me why this code does not work?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub

If runs, but the form won't hide itself. This is the main form of the
application.

to duplicate, just start a brand new windows application, double click the
default form and enter Me.Hide().

I really need this to work. Any thoughts?

Thanks

Kirk

Nov 21 '05 #2
* "Kirk Graves" <kr***********@yahoo.com> scripsit:
Can anyone tell me why this code does not work?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub

If runs, but the form won't hide itself. This is the main form of the
application.

to duplicate, just start a brand new windows application, double click the
default form and enter Me.Hide().

I really need this to work. Any thoughts?


The form is shown directly after the 'Load' event handler has been
executed, so a call to 'Me.Hide' would no do anything because the form
is not yet visible at this time.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #3
Herfried,

thanks for the reply. do you have a solution to my problem? I need the
main form to hide itself without ever showing to the user. I am creating a
TaskBar application and don't want the user to even see the form.

The irritating part is that there are a number of demos for this on the web,
but they all show the main form at startup.

Thanks

Kirk

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uC****************@tk2msftngp13.phx.gbl...
* "Kirk Graves" <kr***********@yahoo.com> scripsit:
Can anyone tell me why this code does not work?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub

If runs, but the form won't hide itself. This is the main form of the
application.

to duplicate, just start a brand new windows application, double click the default form and enter Me.Hide().

I really need this to work. Any thoughts?


The form is shown directly after the 'Load' event handler has been
executed, so a call to 'Me.Hide' would no do anything because the form
is not yet visible at this time.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
* "Kirk Graves" <kr***********@yahoo.com> scripsit:
thanks for the reply. do you have a solution to my problem? I need the
main form to hide itself without ever showing to the user. I am creating a
TaskBar application and don't want the user to even see the form.


Add your code to your form's constructor, or to your 'Sub Main', if you
don't even need a form in your application. You can create a 'Sub
Main', ba adding this code to your application:

\\\
Public Module Program
Public Sub Main()
...
End Sub
End Module
///

Then set the startup object (project properties window) to 'Sub Main'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #5
Kirk,

I assume that you needs to show that form one time a normal situation for
this is that you use a splash form.

When you put the loading of that in the "load event" of your main form, the
splash form will first be showed. At the moment that the "load event" is
completed than will be automaticly showed your main form, something like
this

\\\
Private Sub FormMain_Load(ByVal sender As _
Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim splash As New Form2
splash.ShowDialog(Me)
splash.Dispose()
End Sub
///

I hope this helps?

Cor
Can anyone tell me why this code does not work?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.Hide()
End Sub

If runs, but the form won't hide itself. This is the main form of the
application.

to duplicate, just start a brand new windows application, double click the
default form and enter Me.Hide().

I really need this to work. Any thoughts?

Thanks

Kirk

Nov 21 '05 #6

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

Similar topics

27
by: Nicholas Couch | last post by:
I have a little form with a couple of dynamically generated list boxes. When the user makes a selection from the first box, the second box is refreshed. When they make a selection from the second...
13
by: DS | last post by:
How do you hide the Title Bar for Access the application. I have everything done but I need to hide the title bar. I've seen code to hide Access but that seems like overkill. Can I put hiding...
5
by: Mardy | last post by:
I have an aspx page that contains a drop down and 3 divs and lots of other stuff. I'd like to hide the divs depending on which option from the drop down is selected. It works fine until I do a...
3
by: PAPutzback | last post by:
I have a form that when it loads it fires off a second thread to load a datatable. This datatable contains a list of names and ids that the user may want to add to their criteria. So I have a...
6
by: cargo303 | last post by:
I have a php page with a drop down list, and the default selected option is "Select a location" (without quotes). Using the drop down initiates a database query. One of (3) things should happen: ...
5
by: BD | last post by:
I am coding with C# in Visual Studio 2005 for a database application residing on remote MS SQL Server 2005. What I want to do is open the same form but from 2 different places and only one...
2
by: arti | last post by:
In Asp.net form, I have 3 panels. I want a button on top of each panel to hide or display the panel. I am able to do it. But when there is any postback, the page loads with its design time setting-...
1
by: nithingujjar | last post by:
Hi, I need to to hide a field"addr_state1" based on a value in the drop down list field called "addr_country".i.e.,if addr_country.value=="in" then hide addr_state1 else , and if the value in the...
1
by: ll | last post by:
I'm currently working on a form which consists of a show and hide javascript. The toggle works fine, although when I click on submit, I would like the page to reload with the toggle (show/hide)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.