473,804 Members | 3,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Tex t = "something" ;
--Don't work
--
GoGs
Jan 23 '07 #1
5 2217
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.Tex t = "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;
//InitializeCompo nents(); or whatever you have in your constructor
}

void DoSomethingToFo rm1()
{
this.form1.text Box1.Text = "Foo";
}
}

"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:a2******** *************** ****@msnews.mic rosoft.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.Tex t = "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******** *****@TK2MSFTNG P06.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;
//InitializeCompo nents(); or whatever you have in your constructor
}

void DoSomethingToFo rm1()
{
this.form1.text Box1.Text = "Foo";
}
}

"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:a2******** *************** ****@msnews.mic rosoft.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

gHEEEELLLLLP P
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.Tex t = "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;
//InitializeCompo nents(); or whatever you have in your
constructor
}

void DoSomethingToFo rm1()
{
this.form1.text Box1.Text = "Foo";
}
}
YES... Tnx Veeerrrrryyyy, Thanks
>
"Michael Nemtsev" <ne*****@msn.co mwrote in message
news:a2******** *************** ****@msnews.mic rosoft.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

gHEEEELLLLLP P
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.Tex t = "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
3802
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 http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
5
1857
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 As New PHfx.Form2 to With Events MyForm2 As New PHfx.Form2 and tried adding an event handler but intellisense will not show form2s objects, just the methods.
5
14182
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 variable in form2. Is there a simple method (in VSexpress2005) to get that specific variable in form2? TIA,
9
5272
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 form1 make those variables accessibles everywhere in that form1: Public Class Form1 Inherits System.Windows.Forms.Form Dim TextLine(66) As String
3
2494
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 combobox in Form2 and press "OK". What code should I add to "OK" so that the user can change the colors of a button in Form1? Mateusz
3
5949
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. This code works well for splash screen. I searched alot on net for codes but they don't work. for example- (1) Public Sub CloseForm(formType As System.Type) For Each oForm as System.Windows.Forms.Form in me.MdiParent.MdiChildren If...
3
2484
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 problem is I don't see the items added to the listbox unless I use
7
2568
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 active_this_form()
5
2534
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 pointer to object of class Form1. I don't known how to use method add(), where can I find it. From Form1 I can add value like this this->listBox1- I cant find it. I have textBox1 on Form1 and I can change text in this control like this ...
0
9587
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10085
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7623
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6857
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5527
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5662
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4302
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
2
3827
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2998
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.