473,403 Members | 2,338 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,403 software developers and data experts.

way to read object info in another form/passing parameter like

I know in vb6 it was super easy to pass parameter or either read
example the textbox1.text on the already open form form2

like all object were as public. but is there a way to do something
that easy in c# because i wonder is there is a faster way than the
following example i use right now

to assign a control in another form a value at opening (ex:
textbox1.text)

frmForm2 frm = new frmForm2();
frm.textbox1.text = "bla bla bla";
frm.show();

and here the way i use for example if i would like from frmForm1 read
what's inside the currently opened frmForm2

first in frmForm2 i create a get class like

public string FormTexbox1TextValue
{
get{return this.textbox1.text};
}

and now in form1 i can call it by frmForm2.FormTextbox1TextValue() and
it'll return me the value of his textbox.

so is there any faster way

Sep 6 '07 #1
6 2922
Franck,

You could always change the controls which are members of the form to
public, instead of private. However, you have to be aware of the issues
involved with exposing your control (in other words, you are making it
public, and depending on who is using the form, it might trigger effects you
are not prepared for).

A generally better way of doing this is to expose methods and properties
which will perform the actions on the private members and then call those.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:11*********************@d55g2000hsg.googlegro ups.com...
>I know in vb6 it was super easy to pass parameter or either read
example the textbox1.text on the already open form form2

like all object were as public. but is there a way to do something
that easy in c# because i wonder is there is a faster way than the
following example i use right now

to assign a control in another form a value at opening (ex:
textbox1.text)

frmForm2 frm = new frmForm2();
frm.textbox1.text = "bla bla bla";
frm.show();

and here the way i use for example if i would like from frmForm1 read
what's inside the currently opened frmForm2

first in frmForm2 i create a get class like

public string FormTexbox1TextValue
{
get{return this.textbox1.text};
}

and now in form1 i can call it by frmForm2.FormTextbox1TextValue() and
it'll return me the value of his textbox.

so is there any faster way

Sep 6 '07 #2
as exposing the object property is there a fast way like for example:
public textbox1.text();

something look like this, any example of putting public the text
property of a textbox would be nice

Sep 6 '07 #3
Franck,

In the designer, there should be a row in the property box which allows
you to change the access modifier from private to public.

Or, just change the declaration in the designer-generated code (or
hand-generated, if you are not using a designer) to not be
private/protected.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:11**********************@50g2000hsm.googlegro ups.com...
as exposing the object property is there a fast way like for example:
public textbox1.text();

something look like this, any example of putting public the text
property of a textbox would be nice

Sep 6 '07 #4
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Franck,

In the designer, there should be a row in the property box which allows
you to change the access modifier from private to public.

Or, just change the declaration in the designer-generated code (or
hand-generated, if you are not using a designer) to not be
private/protected.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Franck" <the_darkbl...@hotmail.comwrote in message

news:11**********************@50g2000hsm.googlegro ups.com...
as exposing the object property is there a fast way like for example:
public textbox1.text();
something look like this, any example of putting public the text
property of a textbox would be nice
but in that case it allow the full control of the object

Sep 6 '07 #5
Franck,

Yes, which is the behavior that you get in VB. If you don't want to
expose full control of the object, then you have to expose a method or
property on the hosting control/form which takes the parameters that you
need, and performs the action you want.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Franck" <th***********@hotmail.comwrote in message
news:11**********************@r34g2000hsd.googlegr oups.com...
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>Franck,

In the designer, there should be a row in the property box which
allows
you to change the access modifier from private to public.

Or, just change the declaration in the designer-generated code (or
hand-generated, if you are not using a designer) to not be
private/protected.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Franck" <the_darkbl...@hotmail.comwrote in message

news:11**********************@50g2000hsm.googlegr oups.com...
as exposing the object property is there a fast way like for example:
public textbox1.text();
something look like this, any example of putting public the text
property of a textbox would be nice

but in that case it allow the full control of the object

Sep 6 '07 #6
On Sep 6, 11:40 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Franck,

Yes, which is the behavior that you get in VB. If you don't want to
expose full control of the object, then you have to expose a method or
property on the hosting control/form which takes the parameters that you
need, and performs the action you want.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Franck" <the_darkbl...@hotmail.comwrote in message

news:11**********************@r34g2000hsd.googlegr oups.com...
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Franck,
In the designer, there should be a row in the property box which
allows
you to change the access modifier from private to public.
Or, just change the declaration in the designer-generated code (or
hand-generated, if you are not using a designer) to not be
private/protected.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Franck" <the_darkbl...@hotmail.comwrote in message
>news:11**********************@50g2000hsm.googlegr oups.com...
as exposing the object property is there a fast way like for example:
public textbox1.text();
something look like this, any example of putting public the text
property of a textbox would be nice
but in that case it allow the full control of the object
got it thank you

Sep 6 '07 #7

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

Similar topics

3
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
29
by: web1110 | last post by:
If I have 2 variables, A and B, referencing the same object and then do a A.Dispose(), what happens to B?
11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
8
by: Gawain Lavers | last post by:
I have a script which uses a lot of object augmentation (in order to extend the functionality of DOM elements), and I'm clearly stressing out my browser (I rapidly get to a point where Firefox is...
7
by: Arpan | last post by:
The .NET Framework 2.0 documentation states that An Object variable always holds a pointer to the data, never the data itself. Now w.r.t. the following ASP.NET code snippet, can someone please...
4
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I had a class that worked, but I knew wasn't designed correctly from an OO point of view, so I changed it so it was more like I thought it 'should' be, and now it doesn't always work....
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
45
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
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: 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: 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
marktang
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,...
0
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...
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,...

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.