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

Form2 send to Form1

HEEEELLLLLPP

I hawe two Open form... Form1 and Form2

How I can from Form2 send text to textbox of Form1

//public System.Windows.Forms.TextBox textBox1;
//Form1 fo = new Form1();
//fo.textbox1.Text = "something";
--Don't work
--
GoGs
Jan 23 '07 #1
5 2188
Hello gogs,

Try to use google before asking :)
http://groups.google.com/groups/sear...+between+pages

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

gHEEEELLLLLPP
g>
gI hawe two Open form... Form1 and Form2
g>
gHow I can from Form2 send text to textbox of Form1
g>
g//public System.Windows.Forms.TextBox textBox1;
g//Form1 fo = new Form1();
g//fo.textbox1.Text = "something";
g--Don't work
Jan 23 '07 #2
Hello Michael,

While I agree with you he could have googled first, I'm afraid you misread
gogs' question, he was asking about windows forms, not ASP.NET.

Answer to gogs' question:
Keep in mind that forms are still objects. You can have multiple instances
of a particular form class and changing properties of one won't affect other
instances.
You will need to pass a reference to an instance of Form1 to Form2 (either
in constructor or by using a property), make sure the TextBox you need to
change is visible (public or internal) and change it's Text property as you
wanted to do in the example you've posted.

class Form2 : System.Windows.Forms.Form
{
private Form1 form1;
public Form2(Form1 form1)
{
this.form1 = form1;
//InitializeComponents(); or whatever you have in your constructor
}

void DoSomethingToForm1()
{
this.form1.textBox1.Text = "Foo";
}
}

"Michael Nemtsev" <ne*****@msn.comwrote in message
news:a2***************************@msnews.microsof t.com...
Hello gogs,

Try to use google before asking :)
http://groups.google.com/groups/sear...+between+pages

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

gHEEEELLLLLPP
ggI hawe two Open form... Form1 and Form2
ggHow I can from Form2 send text to textbox of Form1
gg//public System.Windows.Forms.TextBox textBox1;
g//Form1 fo = new Form1();
g//fo.textbox1.Text = "something";
g--Don't work


Jan 23 '07 #3
Heh! Gormod o gogs.

If GoGs is Welsh, he'll understand. If not, well, sorry for this misuse of
bandwidth. Blame coincidence.
Peter

"Lebesgue" <le******@gmail.comwrote in message
news:Om*************@TK2MSFTNGP06.phx.gbl...
Hello Michael,

While I agree with you he could have googled first, I'm afraid you misread
gogs' question, he was asking about windows forms, not ASP.NET.

Answer to gogs' question:
Keep in mind that forms are still objects. You can have multiple instances
of a particular form class and changing properties of one won't affect
other instances.
You will need to pass a reference to an instance of Form1 to Form2 (either
in constructor or by using a property), make sure the TextBox you need to
change is visible (public or internal) and change it's Text property as
you wanted to do in the example you've posted.

class Form2 : System.Windows.Forms.Form
{
private Form1 form1;
public Form2(Form1 form1)
{
this.form1 = form1;
//InitializeComponents(); or whatever you have in your constructor
}

void DoSomethingToForm1()
{
this.form1.textBox1.Text = "Foo";
}
}

"Michael Nemtsev" <ne*****@msn.comwrote in message
news:a2***************************@msnews.microsof t.com...
>Hello gogs,

Try to use google before asking :)
http://groups.google.com/groups/sear...+between+pages

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

gHEEEELLLLLPP
ggI hawe two Open form... Form1 and Form2
ggHow I can from Form2 send text to textbox of Form1
gg//public System.Windows.Forms.TextBox textBox1;
g//Form1 fo = new Form1();
g//fo.textbox1.Text = "something";
g--Don't work



Jan 23 '07 #4

Peter Bradley wrote:
Heh! Gormod o gogs.

If GoGs is Welsh, he'll understand. If not, well, sorry for this misuse of
bandwidth. Blame coincidence.
Peter, I'm a 'gog' so it wasn't wasted!

I think that's enough OT for this thread...

Jan 23 '07 #5
On Tue, 23 Jan 2007 14:13:58 +0100, Lebesgue <le******@gmail.comwrote:
Hello Michael,

While I agree with you he could have googled first, I'm afraid you
misread
gogs' question, he was asking about windows forms, not ASP.NET.

Answer to gogs' question:
Keep in mind that forms are still objects. You can have multiple
instances
of a particular form class and changing properties of one won't affect
other
instances.
You will need to pass a reference to an instance of Form1 to Form2
(either
in constructor or by using a property), make sure the TextBox you needto
change is visible (public or internal) and change it's Text property as
you
wanted to do in the example you've posted.

class Form2 : System.Windows.Forms.Form
{
private Form1 form1;
public Form2(Form1 form1)
{
this.form1 = form1;
//InitializeComponents(); or whatever you have in your
constructor
}

void DoSomethingToForm1()
{
this.form1.textBox1.Text = "Foo";
}
}
YES... Tnx Veeerrrrryyyy, Thanks
>
"Michael Nemtsev" <ne*****@msn.comwrote in message
news:a2***************************@msnews.microsof t.com...
>Hello gogs,

Try to use google before asking :)
http://groups.google.com/groups/sear...+between+pages

---
WBR,
Michael Nemtsev [C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and
we
miss it, but that it is too low and we reach it" (c) Michelangelo

gHEEEELLLLLPP
ggI hawe two Open form... Form1 and Form2
ggHow I can from Form2 send text to textbox of Form1
gg//public System.Windows.Forms.TextBox textBox1;
g//Form1 fo = new Form1();
g//fo.textbox1.Text = "something";
g--Don't work




--
GoGs
Jan 23 '07 #6

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

Similar topics

5
by: nadir b | last post by:
hi I don't know how to change for exemple a form1 caption text from form2 don't forget that form2 has created from form1 I want sample code with c# *** Sent via Developersdex...
5
by: PAPutzback | last post by:
Form2 has one purpose to open and list some names and ids. I want to handle the list box click event on form2 so I can get the selected value onto a field in form1. I changed this Dim MyForm2...
5
by: John | last post by:
Hi, I can't find a simple example for a simple(?) problem. I am working on an application with a variable in form1, that variable is needed in form2 for a calculation but i can't get that...
9
by: Marcel Saucier | last post by:
Hello everybody, I want to declare an array in form1, load it in form1 and then access that array in form2. New in VB, It took me a while to understand that declaring variables right under class...
3
by: Mateusz Rajca | last post by:
Hello, I have Form1 - the main form with some controls including a button. I have Form2 - the properties form with a combobox and button. The user can select the colors of a button in the...
3
by: Karan | last post by:
I am calling finalize when form2 loads and deactivates form1 which closes form1. However, same thing is not happening in form2 because finalize is already called. Does anybody has solution to it....
3
by: R. Harris | last post by:
Hi. I have 2 forms: form1 form2 On Form2 I have a listbox and a button. When I click the button it calls a function from form1 and within that function it updates the listbox on form2. My...
7
by: Boki | last post by:
Hi All, I want to change WindowState of form1 from form2. I tried these two methods, but no luck on both. (1) Declare a public method: /* function of form1 */ public void...
5
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a...
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
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
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...
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.