Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franck - 06 Sep 2007 13:24 GMT
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
Nicholas Paldino [.NET/C# MVP] - 06 Sep 2007 15:46 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.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
[quoted text clipped - 24 lines]
>
> so is there any faster way
Franck - 06 Sep 2007 15:47 GMT
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
Nicholas Paldino [.NET/C# MVP] - 06 Sep 2007 16:10 GMT
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.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.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
Franck - 06 Sep 2007 16:26 GMT
On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> Franck,
>
[quoted text clipped - 14 lines]
> > 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
Nicholas Paldino [.NET/C# MVP] - 06 Sep 2007 16:40 GMT
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.

Signature

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

> On Sep 6, 11:10 am, "Nicholas Paldino [.NET/C# MVP]"
> <m...@spam.guard.caspershouse.com> wrote:
[quoted text clipped - 19 lines]
>
> but in that case it allow the full control of the object
Franck - 06 Sep 2007 17:04 GMT
On Sep 6, 11:40 am, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.com> wrote:
> Franck,
>
[quoted text clipped - 34 lines]
>
> > but in that case it allow the full control of the object

got it thank you

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.