473,413 Members | 1,993 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,413 software developers and data experts.

Q: OnLoad

Can anybody tell me the event I should use if I want a OpenFileDialog to
open as soon as a from has displayed? I tried putting it in the forms OnLoad
but this means that the form isn't fully displayed until the OpenFileDialog
is shutdown.

Many thanks in advance

Geoff
Nov 21 '05 #1
11 1382
Geoff,

Try putting Me.Show before calling the openfiledialog's ShowDialog method.

Kerry Moorman
"Geoff Jones" wrote:
Can anybody tell me the event I should use if I want a OpenFileDialog to
open as soon as a from has displayed? I tried putting it in the forms OnLoad
but this means that the form isn't fully displayed until the OpenFileDialog
is shutdown.

Many thanks in advance

Geoff

Nov 21 '05 #2
Geoff,
Have you considered using the Activate event?

Something like:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
AddHandler Me.Activated, AddressOf MainForm_InitialOpen
End Sub

Private Sub MainForm_InitialOpen(ByVal sender As Object, ByVal e As
System.EventArgs)
RemoveHandler Me.Activated, AddressOf MainForm_InitialOpen
Dim dialog As New OpenFileDialog
dialog.ShowDialog(Me)
End Sub

The AddHandler & RemoveHandler ensure that MainForm_InitialOpen is only
called once.

If I had a number of forms that need the "InitialOpen" event I would
consider putting the above code in a base class that raises an InitialOpen
event, when the first Activated event is called...

My other thought was the Application.Idle event, that you also only allow to
be called once.

Hope this helps
Jay

"Geoff Jones" <no********@email.com> wrote in message
news:43*********************@news.dial.pipex.com.. .
| Can anybody tell me the event I should use if I want a OpenFileDialog to
| open as soon as a from has displayed? I tried putting it in the forms
OnLoad
| but this means that the form isn't fully displayed until the
OpenFileDialog
| is shutdown.
|
| Many thanks in advance
|
| Geoff
|
|
Nov 21 '05 #3
Thanks Jay, that is most useful.

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:%2****************@TK2MSFTNGP11.phx.gbl...
Geoff,
Have you considered using the Activate event?

Something like:

Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
AddHandler Me.Activated, AddressOf MainForm_InitialOpen
End Sub

Private Sub MainForm_InitialOpen(ByVal sender As Object, ByVal e As
System.EventArgs)
RemoveHandler Me.Activated, AddressOf MainForm_InitialOpen
Dim dialog As New OpenFileDialog
dialog.ShowDialog(Me)
End Sub

The AddHandler & RemoveHandler ensure that MainForm_InitialOpen is only
called once.

If I had a number of forms that need the "InitialOpen" event I would
consider putting the above code in a base class that raises an InitialOpen
event, when the first Activated event is called...

My other thought was the Application.Idle event, that you also only allow
to
be called once.

Hope this helps
Jay

"Geoff Jones" <no********@email.com> wrote in message
news:43*********************@news.dial.pipex.com.. .
| Can anybody tell me the event I should use if I want a OpenFileDialog to
| open as soon as a from has displayed? I tried putting it in the forms
OnLoad
| but this means that the form isn't fully displayed until the
OpenFileDialog
| is shutdown.
|
| Many thanks in advance
|
| Geoff
|
|

Nov 21 '05 #4
"Geoff Jones" <no********@email.com> schrieb:
Can anybody tell me the event I should use if I want a OpenFileDialog to
open as soon as a from has displayed? I tried putting it in the forms
OnLoad but this means that the form isn't fully displayed until the
OpenFileDialog is shutdown.


\\\
Private Sub Form1_Activated( _
ByVal sender As Object, _
ByVal e As EventArgs _
) Handles MyBase.Activated
Static IsActivated As Boolean
If Not IsActivated Then
IsActivated = True
Application.DoEvents() ' ...
Me.OpenFileDialog1.ShowDialog()
End If
End Sub
///

In .NET 2.0 Windows Forms forms have a 'Shown' event.

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

Nov 21 '05 #5
Herfried,

Although it is more work, do I like the method Jay shows more.

I am in doubt what I will show next time, when this question is asked.
The way you show it is understandable for everybody, Jays is in my opinion
better.

:-)

Cor
Nov 21 '05 #6
Herfried,
Why the DoEvents? I didn't notice that we needed it, hence I left it out. Am
I missing something?

Its nice to hear about the .NET 2.0 Form.Shown event. I missed it when I was
looking thru the "what's new"...

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eK*************@TK2MSFTNGP15.phx.gbl...
| "Geoff Jones" <no********@email.com> schrieb:
| > Can anybody tell me the event I should use if I want a OpenFileDialog to
| > open as soon as a from has displayed? I tried putting it in the forms
| > OnLoad but this means that the form isn't fully displayed until the
| > OpenFileDialog is shutdown.
|
| \\\
| Private Sub Form1_Activated( _
| ByVal sender As Object, _
| ByVal e As EventArgs _
| ) Handles MyBase.Activated
| Static IsActivated As Boolean
| If Not IsActivated Then
| IsActivated = True
| Application.DoEvents() ' ...
| Me.OpenFileDialog1.ShowDialog()
| End If
| End Sub
| ///
|
| In .NET 2.0 Windows Forms forms have a 'Shown' event.
|
| --
| M S Herfried K. Wagner
| M V P <URL:http://dotnet.mvps.org/>
| V B <URL:http://classicvb.org/petition/>
|
Nov 21 '05 #7
Cor,
FWIW: Herfried's example is almost how my example started out, I had a
Private field instead of a Static variable. Then I thought it would be just
as easy to use AddHandler & RemoveHandler to control the event being called
only once. Ergo the version I posted.

I think its good Herfried showed the alternate method (a field instead of
Add/Remove handler)...

Jay

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:um**************@TK2MSFTNGP10.phx.gbl...
| Herfried,
|
| Although it is more work, do I like the method Jay shows more.
|
| I am in doubt what I will show next time, when this question is asked.
| The way you show it is understandable for everybody, Jays is in my opinion
| better.
|
| :-)
|
| Cor
|
|
Nov 21 '05 #8
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
Why the DoEvents? I didn't notice that we needed it, hence I left it out.
Am
I missing something?


No, you are not missing something. The 'DoEvents' can be removed.

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

Nov 21 '05 #9
Many thanks everybody. As always most helpful.

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u1**************@TK2MSFTNGP14.phx.gbl...
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
Why the DoEvents? I didn't notice that we needed it, hence I left it out.
Am
I missing something?


No, you are not missing something. The 'DoEvents' can be removed.

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

Nov 21 '05 #10
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
Why the DoEvents? I didn't notice that we needed it, hence I left it out.
Am
I missing something?


No, you are not missing something. The 'DoEvents' can be removed.

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

Nov 21 '05 #11
Many thanks everybody. As always most helpful.

Geoff

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:u1**************@TK2MSFTNGP14.phx.gbl...
Jay,

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> schrieb:
Why the DoEvents? I didn't notice that we needed it, hence I left it out.
Am
I missing something?


No, you are not missing something. The 'DoEvents' can be removed.

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

Nov 21 '05 #12

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

Similar topics

4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
6
by: Brian | last post by:
Hi everyone, I'm writing a function (in javascript) that needs to do one thing if the page has not loaded, and another (different) thing if the page has already loaded. I'm looking for a way...
4
by: David Virgil Hobbs | last post by:
My web host inserts banner ads into my html pages. The javascript in these banner ads interferes with the onload triggered javascript functions in my pages. Whether I trigger my javascript...
10
by: berg | last post by:
I'm trying to use the onload event to load a series of urls. What I find is that the onload function is only called one time no matter how large the array. Here is the onload function. var...
3
by: Liming | last post by:
Hi, Here is my situation. I have a textarea on the page. When the page loads, I need it to have some default text (which will be generated dynamically) so I did something like this ...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
4
by: PJ6 | last post by:
Say I have serveral controls, all of which need to emit clientside script to execute on page load. They can't emit to OnLoad = <functionname> because then only one of the scripts will get executed....
3
by: Andrew Poulos | last post by:
I've been asked to add some additional code to HTML that get generated by a 3rd party program. Currently the code that gets generated already includes a window.onload = init; The program lets...
20
by: Mark Anderson | last post by:
Hi, I have this in an external JS library: ///////////////////////// function addMyEvent(){ var obj; if(document.attachEvent) { obj = document.getElementsByTagName('img'); for...
1
by: zebra242 | last post by:
I'm working to get the onLoad function of a javascript to work: the script allows form buttons in html to refer to labeled frames in flash. Which works fine. Now I want to add onLoad...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.