473,545 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
+ 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.c om
http://www.dotnetmonster.com/Uwe/For...neral/200510/1
Oct 26 '05 #1
1 1992
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.c om" <u15083@uwe> wrote in message
news:566ba240aa 8e0@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.c om
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
4658
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 training they have had. What im trying to add to this is an email button which emails the person selected - i've managed to be able to do grab...
4
3218
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 Form2 through the constructor of the Form2. He said that then I'd be able to invoke the textbox control in Form1 (with code in Form2). Since I'm...
5
33070
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 Form1 (main form) and Form2, there is parameter in form2 I have to called from form1. So please would you tell me how? Any way thanks
4
1666
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 of PersonalInfo class, makes a call to the db and fills that class Here's the tricky part:
7
1850
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 forms in an application to find out something, such as if a particular form it loaded, or how many of a particular type of form are loaded. Windows...
1
275
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
6549
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 the following warning when I compile: Warning 2 Accessing a member on 'MYCMS.Form1.GLCurrentUserInfo' may cause a runtime exception because it is a...
11
1773
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 say i have Form1 and Form2. Each form is blank. ( no text boxes or anything ) Very Simple Example: ( i just need a start and then i can modify it...
4
2476
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 well. When i click the button2 in the Form2 , Form2 should close and value in the text box2 should be copied to Form1 Textbox1. I know that I have...
0
7479
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
7411
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
7669
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. ...
1
7439
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5987
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...
0
4962
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
3468
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1901
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
0
722
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.