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

Do I have access to all methods when I pass a reference of a form to another form?

When I pass a reference to my current form, frm_x, when I create and show
another form, frm_y, do I have access to all of the public methods,
controls, members, etc.. of frm_x from frm_y?
In my code, I pass the reference like this:

private void btn_ListEmp_Click(object sender, System.EventArgs e)
{
frm_EmpList frm_empList = new frm_EmpList(this);
frm_empList.MdiParent = this.MdiParent;
frm_empList.Show();
}

---------------------
public Form _frm_emplRec;
public frm_EmpList(DataSet DS_allEmployees, Form frm_emplRec)
{
InitializeComponent();
_frm_emplRec = frm_emplRec;
//_frm_emplRec.txt_ssNum.Text = "MyText"; /* This doesn't compile
although txt_ssNum is public*/
}

How can I pass a reference of the form *and* have control of anything public
inside the form?
Also, is this the best way to pass values from one form to another? If not,
what other option could I use?

Thanks again,
Vaughn
Nov 15 '05 #1
4 1445
"Vaughn" <vo******@yahoo.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl...
When I pass a reference to my current form, frm_x, when I create and show
another form, frm_y, do I have access to all of the public methods,
controls, members, etc.. of frm_x from frm_y?


Hi

Only to public members. Not to protected or private methods.

Nov 15 '05 #2
you could surely be able to get all the methods exposed,
but only if you create an object of the required form
Nov 15 '05 #3
How would I create an object of the form? I suppose that to do that, I need
more code than this:
public Form _frm_emplRec;
public frm_EmpList(DataSet DS_allEmployees, Form frm_emplRec)
{
InitializeComponent();
_frm_emplRec = frm_emplRec;
}

I assumed that with the code above, I'd be able to access all the controls
of the reference (Eg. _frm_emplRec.txt_ssnum.Text = visible;). But the
controls aren't recognized in the compiler.

Thanks again.
"irfan" <an*******@discussions.microsoft.com> wrote in message
news:06****************************@phx.gbl...
you could surely be able to get all the methods exposed,
but only if you create an object of the required form

Nov 15 '05 #4
Hi

The problem is that the type of your field '_frm_emplRec' is 'Form'. The
type 'Form' does not have a public member called 'txt_ssnum', that's why
you are getting a compiler error. This can work in other languages that
support late-binding however C# does not.

You need to declared your '_frm_emplRec' field of the same type as the form
that you are getting.

thx
Gabriel Esparza-Romero, Visual C# Team
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Nov 15 '05 #5

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

Similar topics

6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
55
by: AnandaSim | last post by:
I just had a google through this NG but have not seen mention of Erik Rucker's blog entry and the new Jet: http://blogs.msdn.com/access/archive/2005/10/05/477549.aspx mentioned by Mike...
3
by: Ray Mitchell | last post by:
Hello, I am opening a modal dialog in the standard way using something like: ....all the standard setup stuff... dlg.ShowDialog(); I need the dialog object to be able to access some of the...
3
by: Ray Stevens | last post by:
How do you access properties of the main program's class from another form? There does not apear to be an instance variable that can be used.
4
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of...
0
by: graciezzzzz | last post by:
Hi all, I create a Web Service project called 'eSelectService' and another Class Library project called 'MonerisVO', and a Windows Form project called 'maps' as well. The reason why I need...
11
by: glen.coates.bigworld | last post by:
I'm developing a library at the moment that involves many classes, some of which have "exposed" capabilities. I'm trying to design a nice interface for both exposing those capabilities, and...
3
by: bsturg21 | last post by:
Hello, I have a windows form that has a series of linklabels on it, and I need to have each linklabel, when clicked, open a separate windows form that has a single paramter passed into it. The...
10
by: blangela | last post by:
If I pass a base class object by reference (likely does not make a difference here that it is passed by reference) as a parameter to a derived class member function, the member function is not...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.