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

get Application.mainForm


Is there a way to get the Application.mainForm from any place in the
code, e.g from a shared property of any class ?

Thanks

Atara
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
6 3077
you could declare a public variable of your main form and fill it w the form
in the main form onload event

public mainf as frmMainForm

private sub frmMainForm_Load ...
mainf = me
....
end sub

you should be able to access the mainf

eric
"Atara" <At***@DD.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

Is there a way to get the Application.mainForm from any place in the
code, e.g from a shared property of any class ?

Thanks

Atara
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2
* "EricJ" <ericRéMo**@ThiSomnipack.be> scripsit:
you could declare a public variable of your main form and fill it w the form
in the main form onload event

public mainf as frmMainForm

private sub frmMainForm_Load ...
mainf = me
...
end sub

you should be able to access the mainf


You will have to declare the variable as 'Public Shared'.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
> You will have to declare the variable as 'Public Shared'.

i didn't and it works (it could be a difference that i declare my public
vars in a module) ?
(not being dificult here, but i like to learn more on how these things work
in .NET, so i can write better code in the end (Whidbey ;p))
Nov 20 '05 #4
* "EricJ" <ericRéMo**@ThiSomnipack.be> scripsit:
You will have to declare the variable as 'Public Shared'.

i didn't and it works (it could be a difference that i declare my public
vars in a module) ?


Yes, it's a difference. Variables declared in modules are 'Shared'
automatically.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #5
tnx (now i know that 2 ;) )
Yes, it's a difference. Variables declared in modules are 'Shared'
automatically.

Nov 20 '05 #6
Thanks.

Atara.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7

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

Similar topics

8
by: Simon Harvey | last post by:
Hi everyone, Can anyone tell me if there is any compelling reason not to start my application in a way other than : Application.Run(new MyForm()); I'm not too sure of the implications of...
4
by: Jesse | last post by:
Hi, Can anyone suggest how to go about running a windows application from outside the starting form. ie. making a call to the initial form and then showing it. I have tried this using a...
0
by: | last post by:
Hi there movers & shakers, The example below demonstrates a behaviour that is anoying the tits off of me! It doesn't happen whilst debugging from the IDE only when you run the compiled exe from...
2
by: Robin Tucker | last post by:
Hiya, I have a problem with my application. It hangs around in memory after exiting (and the debugger thinks its still running; I am unable to "break" or "stop" execution). The main loop below...
3
by: Dennis | last post by:
I start my applicaiton from sub Main as follows: <STAThread()>Public Sub Main() Dim MainForm As frm_Main = New frm_Main Application.Run(MainForm) End Sub In the MainForm, I show a Progress...
5
by: Ole | last post by:
The Application.Exit (called from a worker thread) method doesn't cause the OnClosing event handler to be run - is that a default behaviour??? If so - what should I do to properly close all threads...
3
by: Joachim | last post by:
I'm trying to figure out how to make a SmartPart visible on my screen through a SmartPartPlaceHolder. I have the following code (I don't have so much understanding of CAB yet so there might be a...
5
by: Cichy | last post by:
Hello, I'm writing a Client-Server application using sockets (asynchronous). There is a Server (Master) which accepts incoming connections, and Client (Slave). Afetr establishing connections...
4
maxx233
by: maxx233 | last post by:
Hello! I have an app that starts up and has a starting form. One of the icons on this beginning Form opens a new form and lets the user give some information on a task they need to remember to do...
11
by: Andrus | last post by:
Managed code .NET 3.5 C# WinForms application runs OK from Vista when in local drive. When application is copied to mapped network drive or started from \\othercmp\c\myapp\myapp.exe folder , it...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
0
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.