Hi all,
I have a form1 ,in that i have 2 lable and 2 combo boxes. and a
button. when the user clicks the button,i need to pass form1 to form2.
how i can access the form1 controls in form2.
plz help me 3 1308
As a general rule, that isn't a great idea as it breaks encapsulation.
One solution is to mark the protection of the controls as "public"
(which you can do in the designer via the properties window, or in
code) but this is not very nice.
A better approach would depend on what you are doing; you could, for
instance, expose some public events and methods on the second form;
this would allow you to interact / respond, without needing to know
about the implementation details.
Marc
As Mark indicated, there are elegant and not-so-great ways to do this. One
easy way (not necessarily the best or most elegant) is to pass the first form
into the constructor of the second form, and have a field of type Form in the
second:
class Form Secondform
{
private Form _firstForm;
public Form( Form otherForm)
{
_firstForm = otherForm;
}
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com
"bh**************@yahoo.co.in" wrote:
Hi all,
I have a form1 ,in that i have 2 lable and 2 combo boxes. and a
button. when the user clicks the button,i need to pass form1 to form2.
how i can access the form1 controls in form2.
plz help me
Hi,
<bh**************@yahoo.co.inwrote in message
news:11**********************@x35g2000prf.googlegr oups.com...
Hi all,
I have a form1 ,in that i have 2 lable and 2 combo boxes. and a
button. when the user clicks the button,i need to pass form1 to form2.
how i can access the form1 controls in form2.
Just create a constructor in form2 that receive a Form1 instance
Remember to also make the controls (or use properties ) to make the controls
available from form2 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Vanessa |
last post by:
Hi,
I would like to know whether there's any way for me to pass an object by
reference to another form?
Regards
Vanessa
|
by: Lyn |
last post by:
Hi,
I have been experiencing a problem passing a LIKE statement in the WHERE
argument of a DoCmd.Openform statement. I have posted that issue
separately.
However, in an attempt to work around...
|
by: Vaughn |
last post by:
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...
|
by: tom |
last post by:
Hi Experts,
I want to pass the selectedDate value from my calender
form to another web form or a web user control. Could you
please show me how to do this?
Thanks in advance.
|
by: KFactor |
last post by:
Is it possible to pass form variables to a page on another server using
response.redirect?
Or is there a secure way of passing sensitive information from one site to
another such as a userID?
...
|
by: c676228 |
last post by:
Hi,
This is my first time to post asp.net question on this forum.
I have a question for "How to pass the first form value to the next form"
I have enrollinfo.aspx form which look like as follow:...
|
by: Rabbit |
last post by:
Hi,
On my 1st page, i have a function which gets a new ID value and need to
transfer to another immediately.
which I want to get in 2nd page using Request.form("txtID"), but doesn't
work, the...
|
by: Boki |
last post by:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(object sender, EventArgs e)
{
Form1 form_copy = new Form1();
|
by: =?Utf-8?B?Umljaw==?= |
last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child)
but I need an example of passind data from FormA to FormB. My main form is
FormA; I will enter some data in textboxes and...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
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...
|
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...
| |