473,474 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

reference a variable in form1 from form2 in C#?

I have a textbox in form2 that i need to use in form1. How do I get acces to
it? I am having trouble finding an example on this...probably due to
inexperience

thanks
brian
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...neral/200510/1
Oct 26 '05 #1
1 1980
Declare the textbox as public in Form2. Or wrap the textbox property that
you want to access acorss the form as public. For example, to wrap the Text
property of the textbox as a property of Form2, have this in Form2:

public string TextBoxText
{
get {return TextBox1.Text;}
set {TextBox1.Text = value;}
}

Then from Form1,

Form2 x = new Form2();
x.TextBoxText = "My Text";

HTH.
"Brian Underhill via DotNetMonster.com" <u15083@uwe> wrote in message
news:566ba240aa8e0@uwe...
I have a textbox in form2 that i need to use in form1. How do I get acces
to
it? I am having trouble finding an example on this...probably due to
inexperience

thanks
brian
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...neral/200510/1
Oct 26 '05 #2

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

Similar topics

14
by: simonmarkjones | last post by:
Hi, I'm having a bit of trouble editing an old database that was created quite a while ago by someone else. There is a form that lets the user select a member of staff and show details about the...
4
by: Omar Llanos | last post by:
Recently, I posted a question on how to invoke a textbox control in Form1 (parent form) from within Form2 (which is inherited from Form1). Someone suggested to pass a reference of the Form1 to the...
5
by: MMSJED | last post by:
I am beginner in using C#, actually I am trying to move from VB6 to C# I need very small help in programming problem my be you will laugh when you get it That simply I have to form let’s say...
4
by: William Oliveri | last post by:
Is there a way to reference a calling form and pass an object to it? This is what I'm trying to do: Form A creates new instance of Form B and then calls it modal. Form B creates a new instance...
7
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are often fond of looping through the currently loaded...
1
by: Brian Underhill via DotNetMonster.com | last post by:
I have a textbox in form2 that i need to use in form1. How do I get acces to it? I am having trouble finding an example on this...probably due to inexperience thanks brian
4
by: Rob Dob | last post by:
Hi, I have a global structure that I declare within form1.cs, and I need to reference from within other forms, everything seems to work okay at runtime, Everything works okay however I get...
11
by: Miro | last post by:
I am banging my head around something that I think I just dont understand what I am reading in the helps. Its gotta be so simple but I just cant figure out what im reading. ( vb 2003 ) Lets...
4
by: Prashwee | last post by:
Hi All I got a small problem with VB 2005 I have let's say Form1 .Form1 has a Text Box1 and a Button1. When I click the Button1 in a Form1, Form2 opens which has a button2 and a text box2 as...
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
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,...
0
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...
1
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
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.