473,569 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.te xt = "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 FormTexbox1Text Value
{
get{return this.textbox1.t ext};
}

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

so is there any faster way

Sep 6 '07 #1
6 2933
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.co m

"Franck" <th***********@ hotmail.comwrot e in message
news:11******** *************@d 55g2000hsg.goog legroups.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.te xt = "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 FormTexbox1Text Value
{
get{return this.textbox1.t ext};
}

and now in form1 i can call it by frmForm2.FormTe xtbox1TextValue () 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.co m

"Franck" <th***********@ hotmail.comwrot e in message
news:11******** **************@ 50g2000hsm.goog legroups.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.guar d.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.c om

"Franck" <the_darkbl...@ hotmail.comwrot e in message

news:11******** **************@ 50g2000hsm.goog legroups.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.co m

"Franck" <th***********@ hotmail.comwrot e in message
news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.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.c om

"Franck" <the_darkbl...@ hotmail.comwrot e in message

news:11******* *************** @50g2000hsm.goo glegroups.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.guar d.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.c om

"Franck" <the_darkbl...@ hotmail.comwrot e in message

news:11******** **************@ r34g2000hsd.goo glegroups.com.. .
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guar d.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.c om
"Franck" <the_darkbl...@ hotmail.comwrot e in message
>news:11******* *************** @50g2000hsm.goo glegroups.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
45951
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 to find a reference to request or response objects in JavaScript either in Google Groups or O'Reilly's "JavaScript the Definitive Guide" (surely it...
6
2785
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 in C# and we're using remoting for client to server communication.
29
2283
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
3810
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 experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of...
8
1738
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 telling me that the script is "unresponsive", often more than once. I'm not sure if it's simply execution time or memory usage. My question is...
7
2848
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 explain me what does the above statement mean? <script runat="server"> Class Clock
4
1770
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. Works most of the time, but not always. At first, I had an object variable declared in a class, and everything worked fine. Then, I figured I should...
275
12117
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
2981
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 clsData Private m_objSQLClient As clsSQLClient Private m_objUsers As clsUsers
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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...
0
7926
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
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

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.