Click here to Skip to main content
16,017,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<b></b>One of my requirement is
I want to load the form without showing.
Means I have written Code to show the Crystal Report on Form Load event
but when user selects the radio button i.e. want to print the report (on previous form)
so for loading purpose i have to show the form.
My moto is to load the form without showing it.
pls. help me....!
Posted

You can minimize the form or hide it.
Me.WindowState = FormWindowState.Minimized<br />
Me.Hide()
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Jul-11 22:30pm    
Abhinav, there is nothing wrong with this code, but it does not address any OP problem. The problem is different -- there is no such thing as "load". The names Form.Load and Form.OnLoad mislead many. OP can simply forget about it -- there is no loading, only construction and Show/Hide/Activate, etc.

Please see my explanation in my solution.
--Sa
ddrraamm 16-Jul-11 5:37am    
Thanks a Lot....!

just dispose the form
and u r done....


thanks again....
Espen Harlinn 17-Jul-11 7:55am    
Nice reply, my 5
Abhinav S 17-Jul-11 8:02am    
Thanks a ton, Espen.
The problem is: the concept of "loading" the form is purely fictional. The form is created, get shown/hidden and closes. You could be distracted be the event Form.Load. MSDN explains it: "Occurs before a form is displayed for the first time.". There is a protected method Form.OnLoad which is called before showing the form for the first time, which could be overridden.

So, it looks like the sole purpose of "loading" is… calling the user-supplied delegates put in the invocation list of the event Form.Load. There is no loading per se.

You can safely ignore this event and the concept of loading — it does not actually load anything. Create an instance of the form class to show it later, that's it. There is a log of confusion around this fictional concept. I hope I clarified things.

—SA
 
Share this answer
 
Comments
Abhinav S 16-Jul-11 0:16am    
Ok I thought the OP was looking for hiding a form. Thus my answer.
My 5.
Sergey Alexandrovich Kryukov 16-Jul-11 0:28am    
Thank you, Abhinav.
OP says "Load form without showing", which is not hiding. So I then OP was mislead by the misleading "load" term.
--SA
I know this is an old question, but I just stumbled upon it and am pretty surprised no one has mentioned SetVisibleCore:

C#
bool isVisibleCore = false;
protected override void SetVisibleCore(bool value)
{
    base.SetVisibleCore(isVisibleCore);
}

In that code snippet, as long as isVisibleCore remains false, the form will remain invisible.
 
Share this answer
 
This is sort of a hack but I am doing it successfully with opacity = 0 and opacity = 100. This prevents the form from "showing" even if .Show() is called to be able to perform actions in _Load eventhandler.
 
Share this answer
 
Comments
CHill60 3-Aug-21 6:22am    
The form will still appear momentarily. SetVisibleCore makes the form invisible and never visible.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900