473,770 Members | 3,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Instance name of the Main Form of an application

Which is the instance name of the starting form of an application?
I want to access his controls and variables from another form but can't
find the way...

Which is the property I can use and must i cast it in some way?

Thanx,

Giulio

Jul 21 '05 #1
3 1718
Why not passing a reference in the constructor of the other form?
/Henke

"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Which is the instance name of the starting form of an application?
I want to access his controls and variables from another form but can't
find the way...

Which is the property I can use and must i cast it in some way?

Thanx,

Giulio

Jul 21 '05 #2
Henke, thank you for your answer,

But what do you mean exactly?

Thank you

Giulio

Henke wrote:
Why not passing a reference in the constructor of the other form?
/Henke

"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Which is the instance name of the starting form of an application?
I want to access his controls and variables from another form but can't
find the way...

Which is the property I can use and must i cast it in some way?

Thanx,

Giulio



Jul 21 '05 #3
When you create your other forms from the main form, or at some other place,
pass a reference to your main form in the constructor. Like this:

Add a mebmer variable in your child forms:
private MainForm myMainForm;

In the child forms constructor add a parameter
public ChildForm(MainF orm myMainForm)
{
this.myMainForm = myMainForm;
}

When you want to show the child form, from the mainform:
ChildForm childForm = new ChildForm(this) ;
childForm.Show( );

Now it's possible to access the main form from a method in you child form:
private void SomeMethod()
{
string text = myMainForm.Text ;
}

/Henke
"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:OQ******** ********@TK2MSF TNGP11.phx.gbl. ..
Henke, thank you for your answer,

But what do you mean exactly?

Thank you

Giulio

Henke wrote:
Why not passing a reference in the constructor of the other form?
/Henke

"Giulio Mastrosanti" <gi****@cantobe ron.it> skrev i meddelandet
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Which is the instance name of the starting form of an application?
I want to access his controls and variables from another form but can't
find the way...

Which is the property I can use and must i cast it in some way?

Thanx,

Giulio


Jul 21 '05 #4

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

Similar topics

3
2098
by: serge calderara | last post by:
Dear all, I have a vb.net application which start with a sub main procedure. inside this sub main procedure I create a and instance from an assembly x like as follow: sub main() ..... Application.Run(New frmLogin) end sub
6
4672
by: Dmitry Karneyev | last post by:
Hi! I guess this question have been asked a lot of times, but please be tolerant and if you have any ideas share it. The question is: how to make availibale only one instance of application and if second one is loaded it must be close and give focus to first one. Thanks for any advice! Dmitry
2
12052
by: Bill D | last post by:
In a simple Windows forms application, the main form is called Form1. Within this form's class, I refer to the the running instance of this main class as "this" as in this.Text = "NEW TEXT" I want to do something like change this Text on the Form1 window from within another class. Trying Form1.Text = "TEXT FROM CLASS" or Form1.ActiveForm.Text = "TEXT FROM CLASS"
18
5664
by: Steve Barnett | last post by:
I want to ensure that there is only ever one instance of my app running on a single PC at any time. I understand that I can achieve this by using a mutex and, if I can't take ownership of the mutex, I know there is another instance of my program running. Problem is, how do I get the "new" instance to communicate with the "old" instance? The new one will have been started with a command line parameter that I want to pass to the old...
8
1665
by: Li Pang | last post by:
Hi I want to run my app only one instance, i.e. only one session is allowed to display Thank
3
7197
by: Mark Jerde | last post by:
VS 2005. When I google "CSharp single instance form" the returned pages usually use a Mutex or the VB.NET runtime library. http://en.csharp-online.net/Application_Architecture_in_Windows_Forms_2.0%E2%80%94Single-Instance_Detection_and_Management http://www.codeproject.com/csharp/SingleInstanceApplication.asp http://blogs.msdn.com/onoj/archive/2004/06/04/148532.aspx "Program.cs" below seems to work fine. A feature is it restores a...
2
5504
by: Mesan | last post by:
Hello everyone, Thanks to many useful posts in this newsgroup and others, I've been able to come very close to something I've been wanting to do for a very long time. I've figured out how to create a new custom protocol handler in Windows to handle locations like "myProtocol:", which lets me have a shortcut pointing to "myProtocol:myPrimaryKey" and have my application automatically open and display the given account. That's great. I
3
1637
by: pOwner | last post by:
I'm trying to create a pointer to a class in form1.h button1 event handler. It should be simple... but no. This example is as simple as I can make to illustrate the problem: Form1.h (produced with the designer containing a single button) *********************************************************************************** #pragma once namespace MyProject {
3
3944
by: Jon | last post by:
My main form opens up another form, and from this other form, I'd like to access things in the main form. The problem is that although I know the name of the class of the main form (FormMain) I don't know the name of the instance of it since it was generated by the VS C# Express 2005 designer. In program.cs, I notice that there is the line: Application.Run(new FormMain()); I guess I could replace this with: FormMain fMain = new FormMain()...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10059
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10008
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
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3578
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2822
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.