473,778 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't pass data to another form.

Hi All,

I can't pass data to another form:
in form2:

private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}

the form2 will close after button click, but the textbox1 of form1
doesn't change anything.

textbox1 of form1 already set to public.

Please advice.

Best regards,
Boki.

Jul 11 '07 #1
7 2579
On Jul 11, 10:24 am, Boki <bokit...@ms21. hinet.netwrote:
Hi All,

I can't pass data to another form:

in form2:

private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}

the form2 will close after button click, but the textbox1 of form1
doesn't change anything.

textbox1 of form1 already set to public.

Please advice.

Best regards,
Boki.
I have resolved this issue.

I added the new form from the new button of toolbar.

It seems I have to add the new form from right mouse click of solution
explore.

Best regards,
Boki.

Jul 11 '07 #2
On Jul 11, 11:31 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 10:24 am, Boki <bokit...@ms21. hinet.netwrote:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}
the form2 will close after button click, but the textbox1 of form1
doesn't change anything.
textbox1 of form1 already set to public.
Please advice.
Best regards,
Boki.

I have resolved this issue.

I added the new form from the new button of toolbar.

It seems I have to add the new form from right mouse click of solution
explore.

Best regards,
Boki.
OK, sorry, it is not the root cause.

I got strange here, when I show form2 from form1, the string pass
well, but when I pass from form2, it never works.
/* this is form 1 code to show form 2*/
public void button1_Click(o bject sender, EventArgs e)
{
...

Form2 frm2 = new Form2();
frm2.textBox1.T ext = "testing from form1"; /* this line
works well */
frm2.Show();
...

}

namespace Ring_Buffer_Tes t
{
public partial class Form2 : Form
{
public Form2()
{
InitializeCompo nent();
}

private void button1_Click(o bject sender, EventArgs e)
{
Form1 frm = new Form1();
frm.textBox1.Te xt = "dsfsdf"; /* this line makes nothing
happen */
}

private void textBox1_TextCh anged(object sender, EventArgs e)
{

}
}
}
Best regards,
Boki.

Jul 11 '07 #3
On Jul 11, 11:42 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 11:31 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 10:24 am, Boki <bokit...@ms21. hinet.netwrote:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}
the form2 will close after button click, but the textbox1 of form1
doesn't change anything.
textbox1 of form1 already set to public.
Please advice.
Best regards,
Boki.
I have resolved this issue.
I added the new form from the new button of toolbar.
It seems I have to add the new form from right mouse click of solution
explore.
Best regards,
Boki.

OK, sorry, it is not the root cause.

I got strange here, when I show form2 from form1, the string pass
well, but when I pass from form2, it never works.

/* this is form 1 code to show form 2*/
public void button1_Click(o bject sender, EventArgs e)
{
..

Form2 frm2 = new Form2();
frm2.textBox1.T ext = "testing from form1"; /* this line
works well */
frm2.Show();
...

}

namespace Ring_Buffer_Tes t
{
public partial class Form2 : Form
{
public Form2()
{
InitializeCompo nent();
}

private void button1_Click(o bject sender, EventArgs e)
{
Form1 frm = new Form1();
frm.textBox1.Te xt = "dsfsdf"; /* this line makes nothing
happen */
}

private void textBox1_TextCh anged(object sender, EventArgs e)
{

}
}

}

Best regards,
Boki.
OK, new test result.

the code really create a new form, not the original form I was
using...

How to let it only do reference things....
Best regards,
Boki.

Jul 11 '07 #4
On Jul 11, 11:49 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 11:42 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 11:31 am, Boki <bokit...@ms21. hinet.netwrote:
On Jul 11, 10:24 am, Boki <bokit...@ms21. hinet.netwrote:
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}
the form2 will close after button click, but the textbox1 of form1
doesn't change anything.
textbox1 of form1 already set to public.
Please advice.
Best regards,
Boki.
I have resolved this issue.
I added the new form from the new button of toolbar.
It seems I have to add the new form from right mouse click of solution
explore.
Best regards,
Boki.
OK, sorry, it is not the root cause.
I got strange here, when I show form2 from form1, the string pass
well, but when I pass from form2, it never works.
/* this is form 1 code to show form 2*/
public void button1_Click(o bject sender, EventArgs e)
{
..
Form2 frm2 = new Form2();
frm2.textBox1.T ext = "testing from form1"; /* this line
works well */
frm2.Show();
...
}
namespace Ring_Buffer_Tes t
{
public partial class Form2 : Form
{
public Form2()
{
InitializeCompo nent();
}
private void button1_Click(o bject sender, EventArgs e)
{
Form1 frm = new Form1();
frm.textBox1.Te xt = "dsfsdf"; /* this line makes nothing
happen */
}
private void textBox1_TextCh anged(object sender, EventArgs e)
{
}
}
}
Best regards,
Boki.

OK, new test result.

the code really create a new form, not the original form I was
using...

How to let it only do reference things....

Best regards,
Boki.
Hi

I try this way in form2:

private void button1_Click(o bject sender, EventArgs e)
{
Form1.update_ms g_string(textBo x1.Text.ToStrin g());
}
and put this in form1:

public void update_msg_stri ng(string msg_str)
{
textBox1.Text = msg_str;
}
No luck yet, ....

Boki.

Jul 11 '07 #5
When you have one form create another that requires data to be exchanged, it
is not advisable to directly manipulate controls on the other form.

There are a number of ways to pass info between forms

eg in form1 you may have

Form2 form2 = new Form2 ();
form2.Tag = someObject;
form2.Show();
and in form2_Shown you can have
MyObject o = (MyObject) Tag;

You can also set properties in Form2 eg

public string SetMyText
{
get { myControl.Text = value; }
}
and in Form1 you would have
form2.SetMyText = "aaaa";

or you can use functions, event handlers etc
"Boki" <bo******@ms21. hinet.netwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
Hi All,

I can't pass data to another form:
in form2:

private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}

the form2 will close after button click, but the textbox1 of form1
doesn't change anything.

textbox1 of form1 already set to public.

Please advice.

Best regards,
Boki.
Jul 11 '07 #6
It's very early in the morning here

set { myControl.Text = value; } // not 'get'

"Ian Semmel" <an****@rocketc omp.com.auwrote in message
news:#N******** ******@TK2MSFTN GP04.phx.gbl...
When you have one form create another that requires data to be exchanged,
it is not advisable to directly manipulate controls on the other form.

There are a number of ways to pass info between forms

eg in form1 you may have

Form2 form2 = new Form2 ();
form2.Tag = someObject;
form2.Show();
and in form2_Shown you can have
MyObject o = (MyObject) Tag;

You can also set properties in Form2 eg

public string SetMyText
{
get { myControl.Text = value; }
}
and in Form1 you would have
form2.SetMyText = "aaaa";

or you can use functions, event handlers etc
"Boki" <bo******@ms21. hinet.netwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
>Hi All,

I can't pass data to another form:
in form2:

private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}

the form2 will close after button click, but the textbox1 of form1
doesn't change anything.

textbox1 of form1 already set to public.

Please advice.

Best regards,
Boki.
Jul 11 '07 #7
On Jul 12, 3:29 am, "Ian Semmel" <any...@rocketc omp.com.auwrote :
It's very early in the morning here

set { myControl.Text = value; } // not 'get'

"Ian Semmel" <any...@rocketc omp.com.auwrote in message

news:#N******** ******@TK2MSFTN GP04.phx.gbl...
When you have one form create another that requires data to be exchanged,
it is not advisable to directly manipulate controls on the other form.
There are a number of ways to pass info between forms
eg in form1 you may have
Form2 form2 = new Form2 ();
form2.Tag = someObject;
form2.Show();
and in form2_Shown you can have
MyObject o = (MyObject) Tag;
You can also set properties in Form2 eg
public string SetMyText
{
get { myControl.Text = value; }
}
and in Form1 you would have
form2.SetMyText = "aaaa";
or you can use functions, event handlers etc
"Boki" <bokit...@ms21. hinet.netwrote in message
news:11******** **************@ k79g2000hse.goo glegroups.com.. .
Hi All,
I can't pass data to another form:
in form2:
private void button1_Click(o bject sender, EventArgs e)
{
Form1 form_copy = new Form1();
form_copy.textB ox1.Text = "DSFDSFDS";
this.Close();
}
the form2 will close after button click, but the textbox1 of form1
doesn't change anything.
textbox1 of form1 already set to public.
Please advice.
Best regards,
Boki.
Why got up so early today ?

Jul 12 '07 #8

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

Similar topics

1
2256
by: vishal | last post by:
hi i am using get method to pass data from one form to another and my value may contain & symbol. so when this is case the value after & sign is truncated which is logically true. so what should i do to solve this problem and if value contain ? symbol then it will make any difference????? i have not checked this but just it came in mind right now so i am
4
1652
by: sparks | last post by:
We have a database that reads in and formats raw data. We were using queries to format the data per person and outputing reports. The other database has the persons personal information. I changed the queries on the raw data to maketables, copied the reports into the personal info database and they have the reports from the raw data available for the reports. NOW they want the reports to be displayed as a new tab in the forms. I am not...
3
3890
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around the problem, I thought of using OPENARGS to pass information to the form being opened (instead of using WHERE). In the parent form, I have generated a RecordSet (RS) with the information
3
2259
by: Chung | last post by:
Hi all, I have used the following code for doing the form submission. I don't think this is a right way to submit a from to a new aspx page because I need to add a dummy form in between. Could anyone tell me a proper way to do this? Looking forward to your reply. Thanks!
4
4804
by: tom | last post by:
Hi Experts, I want to pass the selectedDate value from my calender form to another web form or a web user control. Could you please show me how to do this? Thanks in advance.
2
3193
by: KFactor | last post by:
Is it possible to pass form variables to a page on another server using response.redirect? Or is there a secure way of passing sensitive information from one site to another such as a userID? I would like to avoid using the querystring. This is what I would like to do: When a user clicks on the link, I need to add them to the database and then
2
2513
by: c676228 | last post by:
Hi, This is my first time to post asp.net question on this forum. I have a question for "How to pass the first form value to the next form" I have enrollinfo.aspx form which look like as follow: <form id="Form1" method="post" runat="server"> <Subway:Address id="address" runat="server" Caption="Home Address"></Subway:Address> <p></p> <SUBWAY:PEOPLEINFO id="Peopleinfo" runat="server" Caption="Employee Information"></SUBWAY:PEOPLEINFO>
17
7079
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the returned value is "" Anybody know how to set this value on 1st page properly, in order to let 2nd page catch it? I don't want to use querystring to pass this value!
14
3608
by: =?Utf-8?B?Umljaw==?= | last post by:
I have seen examples of passing data from FormB to FormA (Parent To Child) but I need an example of passind data from FormA to FormB. My main form is FormA; I will enter some data in textboxes and click a button to bring up FormB which needs to display values entered in FormA. Thanks in advance.
0
9629
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9465
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
10296
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
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...
0
8954
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7474
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
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4031
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

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.